dpctl.tensor.take_along_axis¶
- dpctl.tensor.take_along_axis(x, indices, /, *, axis=-1, mode='wrap')[source]¶
Returns elements from an array at the one-dimensional indices specified by
indicesalong a providedaxis.- Parameters:
x (usm_ndarray) – input array. Must be compatible with
indices, except for the axis (dimension) specified byaxis.indices (usm_ndarray) – array indices. Must have the same rank (i.e., number of dimensions) as
x.axis – int axis along which to select values. If
axisis negative, the function determines the axis along which to select values by counting from the last dimension. Default:-1.mode (str, optional) –
How out-of-bounds indices will be handled. Possible values are:
"wrap": clamps indices to (-n <= i < n), then wraps negative indices."clip": clips indices to (0 <= i < n).
Default:
"wrap".
- Returns:
an array having the same data type as
x. The returned array has the same rank (i.e., number of dimensions) asxand a shape determined according to broadcasting rules, except for the axis (dimension) specified byaxiswhose size must equal the size of the corresponding axis (dimension) inindices.- Return type:
Note
Treatment of the out-of-bound indices in
indicesarray is controlled by the value ofmodekeyword.