reminisce commented on a change in pull request #14315: [numpy] Shape support 
scalar tensor
URL: https://github.com/apache/incubator-mxnet/pull/14315#discussion_r262735160
 
 

 ##########
 File path: include/mxnet/tensor_blob.h
 ##########
 @@ -196,6 +196,10 @@ class TBlob {
     CHECK(mshadow::DataType<DType>::kFlag == type_flag_)
       << "TBlob.get_with_shape: data type do not match specified type."
       << "Expected: " << type_flag_ << " v.s. given " << 
mshadow::DataType<DType>::kFlag;
+    // if scalar, handle it with special care
+    if (ndim() == 0) {
+      return this->get_with_shape<Device, 2, DType>(mshadow::Shape2(1, 1), 
stream);
 
 Review comment:
   Because this line would crash.
   ```cpp
   shape_[shape_.ndim() - 1],
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to