cunumeric.take_along_axis#

cunumeric.take_along_axis(a: ndarray, indices: ndarray, axis: int | None) ndarray#

Take values from the input array by matching 1d index and data slices.

This iterates over matching 1d slices oriented along the specified axis in the index and data arrays, and uses the former to look up values in the latter. These slices can be different lengths.

Functions returning an index along an axis, like cunumeric.argsort() and cunumeric.argpartition(), produce suitable indices for this function.

Parameters:
  • arr (ndarray (Ni..., M, Nk...)) – Source array

  • indices (ndarray (Ni..., J, Nk...)) – Indices to take along each 1d slice of arr. This must match the dimension of arr, but dimensions Ni and Nj only need to broadcast against arr.

  • axis (int) – The axis to take 1d slices along. If axis is None, the input array is treated as if it had first been flattened to 1d, for consistency with cunumeric.sort() and cunumeric.argsort().

Returns:

out – The indexed result. It is going to be a view to arr for most cases, except the case when axis=Null and arr.ndim>1.

Return type:

ndarray (Ni…, J, Nk…)

Availability:

Multiple GPUs, Multiple CPUs