Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
make stack use faster API (#20059)
Browse files Browse the repository at this point in the history
  • Loading branch information
barry-jin authored Jun 1, 2021
1 parent 57d0ace commit 90aaca3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/mxnet/numpy/multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def _get_np_advanced_indexing(self, key):
if type(idcs) == NDArray: # pylint: disable=unidiomatic-typecheck
idcs = idcs.as_np_ndarray()
else:
idcs = _npi.stack(*[i if isinstance(i, self.__class__) else i.as_np_ndarray() for i in idcs])
idcs = _mx_nd_np.stack([i if isinstance(i, self.__class__) else i.as_np_ndarray() for i in idcs])
sliced = _npi.gather_nd(self, idcs)
# Reshape due to `None` entries in `key`.
if new_axes:
Expand All @@ -523,7 +523,7 @@ def _set_np_advanced_indexing(self, key, value):
if type(idcs) == NDArray: # pylint: disable=unidiomatic-typecheck
idcs = idcs.as_np_ndarray()
else:
idcs = _npi.stack(*[i if isinstance(i, self.__class__) else i.as_np_ndarray() for i in idcs])
idcs = _mx_nd_np.stack([i if isinstance(i, self.__class__) else i.as_np_ndarray() for i in idcs])
vshape = get_oshape_of_gather_nd_op(self.shape, idcs.shape)
value_nd = self._prepare_value_nd(value, bcast_shape=vshape, squeeze_axes=new_axes)
self._scatter_set_nd(value_nd, idcs)
Expand Down Expand Up @@ -769,7 +769,7 @@ def __getitem__(self, key):
all((isinstance(arr, NDArray) and _np.issubdtype(arr.dtype, _np.integer) and \
arr.ndim > 0) for arr in key):
# Equivalent case in numpy/_symbol.py
return _npi.advanced_indexing_multiple(self, _npi.stack(*key))
return _npi.advanced_indexing_multiple(self, _mx_nd_np.stack(key))
elif isinstance(key, tuple) and dc.is_deferred_compute():
# Equivalent to isinstance(key, tuple) case in numpy/_symbol.py
# Only enabled in deferred compute mode, as this codepath prevents
Expand Down

0 comments on commit 90aaca3

Please sign in to comment.