sxjscience commented on a change in pull request #17452: Fix indexing with zero
dim array
URL: https://github.com/apache/incubator-mxnet/pull/17452#discussion_r372234323
##########
File path: python/mxnet/ndarray/ndarray.py
##########
@@ -3055,6 +3060,8 @@ def get_indexing_dispatch_code(key):
return _NDARRAY_EMPTY_TUPLE_INDEXING
if getattr(idx, 'dtype', None) == np.bool_:
num_bools += 1
+ if getattr(idx, 'ndim', None) == 0: # zero-dim array as index
treated as integer
Review comment:
@haojin2 @reminisce I realized that we should have already handled the
ndim=0 case. In the `indexing_key_expand_implicit_axes` function, we will
convert the 0-dim array to python types by call `.item()`.
https://github.com/apache/incubator-mxnet/blob/910c608f682a47fc2c43375b5f5a426b563e5821/python/mxnet/ndarray/ndarray.py#L2975
We will always call `indexing_key_expand_implicit_axes` before
`get_indexing_dispatch_code`.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services