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 2020/08/17 22:54:31 UTC

[GitHub] [incubator-mxnet] Zha0q1 opened a new issue #18953: Behavior difference betwen np.broadcast_to and npx.broadcast_like

Zha0q1 opened a new issue #18953:
URL: https://github.com/apache/incubator-mxnet/issues/18953


   ```
   import mxnet
   from mxnet import np, npx
   
   A = np.ones((10))
   B = np.broadcast_to(A, (2, 10))
   print(B.shape)
   # errors out
   #C = npx.broadcast_like(A, B)
   # works
   C = npx.broadcast_like(A.reshape(1, 10), B)
   print(C.shape)
   ```
   
   np.broadcast_to can broadcast (x, ) to (2, x) but npx.braodcast_like cannot. 
   ```
   ubuntu@ip-172-31-10-124:~/incubator-mxnet$ python broadcast_comparision.py 
   [22:53:51] ../src/storage/storage.cc:198: Using Pooled (Naive) StorageManager for CPU
   (2, 10)
   Traceback (most recent call last):
     File "broadcast_comparision.py", line 8, in <module>
       C = npx.broadcast_like(A, B)
     File "<string>", line 61, in broadcast_like
     File "/home/ubuntu/incubator-mxnet/python/mxnet/_ctypes/ndarray.py", line 91, in _imperative_invoke
       ctypes.byref(out_stypes)))
     File "/home/ubuntu/incubator-mxnet/python/mxnet/base.py", line 246, in check_call
       raise get_last_ffi_error()
   mxnet.base.MXNetError: Traceback (most recent call last):
     File "../src/operator/tensor/./broadcast_reduce_op.h", line 446
   MXNetError: Check failed: lhs_shape.ndim() == rhs_shape.ndim() (1 vs. 2) : Operand of shape [10] cannot be broadcasted to [2,10]
   ```
   
   Is there any reason to make them different? Otherwise should we make them consistent?


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



[GitHub] [incubator-mxnet] szha closed issue #18953: Behavior difference betwen np.broadcast_to and npx.broadcast_like

Posted by GitBox <gi...@apache.org>.
szha closed issue #18953:
URL: https://github.com/apache/incubator-mxnet/issues/18953


   


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



[GitHub] [incubator-mxnet] szha commented on issue #18953: Behavior difference betwen np.broadcast_to and npx.broadcast_like

Posted by GitBox <gi...@apache.org>.
szha commented on issue #18953:
URL: https://github.com/apache/incubator-mxnet/issues/18953#issuecomment-678048033


   `np.boradcast_to`, like all other operations in mx.np namespace, needs to be consistent with its numpy counter-part. if they need to be made consistent, then we should drop the one in npx.


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



[GitHub] [incubator-mxnet] szha edited a comment on issue #18953: Behavior difference betwen np.broadcast_to and npx.broadcast_like

Posted by GitBox <gi...@apache.org>.
szha edited a comment on issue #18953:
URL: https://github.com/apache/incubator-mxnet/issues/18953#issuecomment-678048033


   `np.broadcast_to`, like all other operations in mx.np namespace, needs to be consistent with its numpy counter-part. if they need to be made consistent, then we should drop the one in npx.


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