apeforest commented on a change in pull request #16570: 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_r339542098
 
 

 ##########
 File path: python/mxnet/ndarray/ndarray.py
 ##########
 @@ -155,6 +155,15 @@ 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:
+        # When shape is larger than unit32 then there is an overflow error at 
python end itself.
+        # It needs to be caught here since the call doesn't even reach backend.
+        size = 1
+        for idx in shape:
+            size = size * idx
+        if size > 2**31:
 
 Review comment:
   Can we use 2**31 as a constant instead of expression here to save some 
runtime?

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