[object Object]

[object Object][object Object]undefined
[object Object]
  • Description: Extracts elements from the specified dimension dim of the input tensor based on the index number in index, and saves the elements to the out tensor. 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}.

  • Formula:

    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

    [object Object]
    • [object Object]Atlas inference products[object Object] and [object Object]Atlas training products[object Object]: The data type cannot be BFLOAT16.
  • Returns

    [object Object]: status code. For details, see .

    The first-phase API implements input parameter validation. The following error codes may be returned.

    [object Object]
[object Object]
  • Parameters

    [object Object]
  • Returns

    [object Object]: status code. For details, see .

[object Object]
  • When the shape of self is [], the shape of index can only be [1].

  • Deterministic computation:

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

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

[object Object]