[object Object]

[object Object][object Object]undefined
[object Object]

Description: Extracts elements from the input tensor along the specified dimension dim according to the indices in index, and stores them into the output tensor out. For example, given the input tensor self=[123456789]self=\begin{bmatrix}1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9\end{bmatrix} and the index tensor index = [1, 0], self.index_select(0, index) returns: y=[456123]y=\begin{bmatrix}4 & 5 & 6 \\ 1 & 2 & 3\end{bmatrix}.

x.index_select(1, index) returns: y=[215487]y=\begin{bmatrix}2 & 1\\ 5 & 4\\8 & 7\end{bmatrix}.

Computation process: Taking a 3D tensor with shape (3,2,2) as an example: self = [[[1,2],[3,4]],[[5,6],[7,8]],[[9,10],[11,12]]]\begin{bmatrix}[[1,&2],&[3,&4]], \\ [[5,&6],&[7,&8]], \\ [[9,&10],&[11,&12]]\end{bmatrix}, with index=[1, 0], where index is 1D. Let ll, mm, and nn denote the indices for dimensions 0, 1, and 2 of self, respectively.

When dim is 0, index_select(0, index): I=index[i];    out[i][m][n][i][m][n] = self[I][m][n][I][m][n]

When dim is 1, index_select(1, index): J=index[j];     out[l][j][n][l][j][n] = self[l][J][n][l][J][n]

When dim is 2, index_select(2, index): K=index[k];   out[l][m][k][l][m][k] = self[l][m][K][l][m][K]

[object Object]

Each operator has calls. First, aclnnIndexSelectGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation flow. Then, aclnnIndexSelect is called to perform computation.

  • [object Object]
  • [object Object]
[object Object]
  • Parameters

    • self (aclTensor*, input): aclTensor on the device. are supported. The can be ND, NCHW, NHWC, HWCN, NDHWC, or NCDHW. The tensor must have at most 8 dimensions.
      • [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, BFLOAT16, INT64, INT32, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, COMPLEX64, or COMPLEX128.
      • [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT, FLOAT16, INT64, INT32, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, COMPLEX64, or COMPLEX128.
    • dim (int64_t, input): specified dimension. The value is of the INT64 type, within the range [–self.dim(), self.dim() – 1].
    • index (aclTensor*, input): index. This tensor is a device-side aclTensor. Its data type can be INT64 or INT32. are supported. The can be ND, NCHW, NHWC, HWCN, NDHWC, or NCDHW. The tensor is limited to 0D or 1D. For a 0D tensor, it is treated as a 1D tensor with a size of 1. The indices in index must be in the range [0, self.shape[dim]).
    • out (aclTensor, output): device-side aclTensor for output. Its data type and number of dimensions are the same as those of self. The size of the dim dimension equals the length of index, while all other dimensions match those of self. The can be ND, NCHW, NHWC, HWCN, NDHWC, or NCDHW.
      • [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, BFLOAT16, INT64, INT32, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, COMPLEX64, or COMPLEX128.
      • [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT, FLOAT16, INT64, INT32, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, COMPLEX64, or COMPLEX128.
    • workspaceSize (uint64_t*, output): size of the workspace to be allocated on the device.
    • executor (aclOpExecutor**, output): operator executor, containing the operator computation flow.
  • Returns

    aclnnStatus: status code. For details, see .

[object Object]
[object Object]
  • Parameters

    • workspace (void *, input): address of the workspace to be allocated on the device.
    • workspaceSize (uint64_t, input): size of the workspace to be allocated on the device, which is obtained by calling the first-phase API aclnnIndexSelectGetWorkspaceSize.
    • executor (aclOpExecutor *, input): operator executor, containing the operator computation flow.
    • stream (aclrtStream, input): stream for executing the task.
  • Returns

    aclnnStatus: status code. For details, see .

[object Object]
  • Deterministic computation:
    • aclnnIndexSelect defaults to a deterministic implementation.
[object Object]

The following example is for reference only. For details, see .

[object Object]