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_r337262526
 
 

 ##########
 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:
   Generally I'd say ArgumentException, but you can also let the backend handle 
throwing an error

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