[object Object]

[object Object][object Object]undefined
[object Object]
  • Description: Gathers data of a specific dimension dim in the input tensor.

  • Formula: Assume that selfself indicates a tensor, dd indicates a dimension, and indexindex indicates an index tensor. If nn is defined as the dimension of selfself, idi_d is the index of dd, and indexidindex_{i_d} indicates the idi_dth index value of tensor indexindex in dimension dd. To gather data of the specific dimension d, use the following formula:

    gather(X,index,d)i0,i1,,id1,id+1,,in1=selfi0,i1,,id1,indexid,id+1,,in1gather(X,index,d)_{i_0,i_1,\cdots,i_{d-1},i_{d+1},\cdots,i_{n-1}} = self_{i_0,i_1,\cdots,i_{d-1},index_{i_d},i_{d+1},\cdots,i_{n-1}}
  • Example:

    • Example 1: Assume that the input tensor self = [123456789]\begin{bmatrix}1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9\end{bmatrix} and the index tensor index = [0210]\begin{bmatrix}0 & 2\\ 1 & 0\end{bmatrix} with dim = 0. Then, the output tensor out = [1842]\begin{bmatrix}1 & 8\\ 4 & 2\end{bmatrix}. The calculation process is as follows:

      out0,0=selfindex0,0,0=self0,0=1out0,1=selfindex0,1,1=self2,1=8out1,0=selfindex1,0,0=self1,0=4out1,1=selfindex1,1,1=self0,1=2\begin{aligned} out_{0,0}&=self_{index_{0,0}, 0}=self_{0,0}=1 \\ out_{0,1}&=self_{index_{0,1}, 1}=self_{2,1}=8 \\ out_{1,0}&=self_{index_{1,0}, 0}=self_{1,0}=4 \\ out_{1,1}&=self_{index_{1,1}, 1}=self_{0,1}=2 \end{aligned}
    • Example 2: Assume that the input tensor self = [123456789]\begin{bmatrix}1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9\end{bmatrix} and the index tensor index = [0210]\begin{bmatrix}0 & 2\\ 1 & 0\end{bmatrix} with dim = 1. Then, the output tensor out = [1354]\begin{bmatrix}1 & 3\\ 5 & 4\end{bmatrix}. The calculation process is as follows:

      out0,0=self0,index0,0=self0,0=1out0,1=self0,index0,1=self0,2=3out1,0=self1,index1,0=self1,1=5out1,1=self1,index1,1=self1,0=4\begin{aligned} out_{0,0}&=self_{0, index_{0,0}}=self_{0,0}=1 \\ out_{0,1}&=self_{0, index_{0,1}}=self_{0,2}=3 \\ out_{1,0}&=self_{1, index_{1,0}}=self_{1,1}=5 \\ out_{1,1}&=self_{1, index_{1,1}}=self_{1,0}=4 \end{aligned}
[object Object]

Each operator has calls. First, aclnnGatherGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnGather is called to perform computation.

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

    [object Object]
  • Returns

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

    The first-phase API implements input parameter verification. The following errors may be thrown.

    [object Object]
[object Object]
  • Parameters

    [object Object]
  • Returns

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

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

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

[object Object]