reminisce commented on a change in pull request #10889: [MXNET-382] Shape and Size Operator URL: https://github.com/apache/incubator-mxnet/pull/10889#discussion_r191872060
########## File path: src/operator/tensor/elemwise_unary_op.h ########## @@ -388,6 +388,43 @@ void CastCompute(const nnvm::NodeAttrs& attrs, }); } +template<typename xpu> +void ShapeCompute(const nnvm::NodeAttrs& attrs, + const OpContext& ctx, + const std::vector<TBlob>& inputs, + const std::vector<OpReqType>& req, + const std::vector<TBlob>& outputs) { + CHECK_EQ(inputs.size(), 1U); + CHECK_EQ(outputs.size(), 1U); + CHECK_EQ(req.size(), 1U); + const TBlob& in_data = inputs[0]; + const TBlob& out_data = outputs[0]; + mshadow::Stream<xpu> *s = ctx.get_stream<xpu>(); + const TShape& in_shape = in_data.shape_; + MSHADOW_TYPE_SWITCH(out_data.type_flag_, DType, { + mxnet_op::Kernel<mshadow_op::identity_with_cast, xpu>::Launch( + s, in_data.ndim(), out_data.dptr<int64_t>(), in_shape.data()); Review comment: `in_shape.data` is a pointer in cpu memory which cannot be directly accessed on gpu. You can use `Shape<ndim>` instead. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services