reminisce commented on a change in pull request #15698: Numpy Identity operator
URL: https://github.com/apache/incubator-mxnet/pull/15698#discussion_r311281381
##########
File path: src/operator/numpy/np_init_op.h
##########
@@ -107,6 +108,43 @@ void NumpyEyeFill(const nnvm::NodeAttrs& attrs,
EyeFillImpl<xpu>(outputs[0], ctx, req, num_cols, param.N, param.k);
}
+template<int req>
+struct identity {
+ template<typename DType>
+ MSHADOW_XINLINE static void Map(index_t i, DType* out_data, const int n) {
+ using namespace mxnet_op;
+
+ auto j = unravel(i, mshadow::Shape2(n, n));
Review comment:
Calculate j manually. `unravel` is slow.
```cpp
const index_t row_id = i / n;
const index_t col_id = i % n;
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services