cunumeric.put_along_axis#

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

Put values into the destination 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 place values into 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:
  • a (ndarray (Ni..., M, Nk...)) – Destination array.

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

  • values (array_like (Ni..., J, Nk...)) – values to insert at those indices. Its shape and dimension are broadcast to match that of indices.

  • axis (int) – The axis to take 1d slices along. If axis is None, the destination array is treated as if a flattened 1d view had been created of it. axis=None case is currently supported only for 1D input arrays.

Note

Having duplicate entries in indices will result in undefined behavior since operation performs asynchronous update of the arr entries.

Availability:

Multiple GPUs, Multiple CPUs