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 and the index tensor index = [1, 0], self.index_select(0, index) returns: .
x.index_select(1, index) returns: .
Formula:
Taking a 3D tensor with shape (3,2,2) as an example: self = , with index=[1, 0], where index is 1D. Let , , and denote the indices for dimensions 0, 1, and 2 of self, respectively.
When dim is 0, index_select(0, index): I=index[i]; out = self
When dim is 1, index_select(1, index): J=index[j]; out = self
When dim is 2, index_select(2, index): K=index[k]; out = self
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.
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]
When the shape of self is [], the shape of index can only be [1].
Deterministic computation:
- aclnnIndexSelect defaults to a deterministic implementation.
The following example is for reference only. For details, see .