marcoabreu commented on a change in pull request #16570: [WIP]Showing proper 
error message when an attempt is made to create large tensor but MXNet is not 
built with it
URL: https://github.com/apache/incubator-mxnet/pull/16570#discussion_r337259079
 
 

 ##########
 File path: python/mxnet/ndarray/ndarray.py
 ##########
 @@ -155,6 +155,11 @@ def _new_alloc_handle(shape, ctx, delay_alloc, 
dtype=mx_real_t):
             ctypes.c_int(int(_DTYPE_NP_TO_MX[np.dtype(dtype).type])),
             ctypes.byref(hdl)))
     else:
+        size = 1
+        for idx in shape:
+            size = size * idx
+        if size > 2**32:
+            print("Size of tensor you are trying to allocate is larger than 
2^32 elements. Please build with flag USE_INT64_TENSOR_SIZE=1")
 
 Review comment:
   Error?! Or if it's handled in the backend, we should just let it be handled 
there and not duplicate the check

----------------------------------------------------------------
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