You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/05/29 19:11:06 UTC

[GitHub] [incubator-mxnet] szha commented on a change in pull request #15090: Loosen the constraint on serializing/deserializing ndarrays in np_shape semantics

szha commented on a change in pull request #15090: Loosen the constraint on serializing/deserializing ndarrays in np_shape semantics
URL: https://github.com/apache/incubator-mxnet/pull/15090#discussion_r288725853
 
 

 ##########
 File path: src/ndarray/ndarray.cc
 ##########
 @@ -1582,8 +1582,14 @@ static const uint32_t NDARRAY_V2_MAGIC = 0xF993fac9;
 
 void NDArray::Save(dmlc::Stream *strm) const {
   // TODO(junwu): Support this after NumPy operators are merged
-  CHECK(!Imperative::Get()->is_np_shape())
-      << "Saving ndarray within the scope of np_shape is not supported.";
+  if (Imperative::Get()->is_np_shape()) {
+    CHECK_EQ(storage_type(), kDefaultStorage)
+        << "only allow serializing ndarray of default storage type within the scope of np_shape";
+    CHECK_NE(shape_.Size(), 0U)
+        << "serializing zero-size ndarray within the scope of np_shape is not supported";
+    CHECK_NE(shape_.ndim(), 0)
+        << "serializing scalar ndarray within the scope of np_shape is not supported";
+  }
   // write magic number to mark this version
   // for storage type
   strm->Write(NDARRAY_V2_MAGIC);
 
 Review comment:
   would there be any need to differentiate the two arrays?

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


With regards,
Apache Git Services