This API is used to fill the values in the src tensor into the self tensor one by one according to the specified axis and the position relationship in the index tensor. If more than one src value is filled into the same position of the self tensor, these values will be accumulated at this position.
Example: For a 3D tensor, self is updated according to the following rules:
[object Object]The following conditions must be met during computation:
- self, index, and src must have the same number of dimensions.
- For each dimension d, index.size(d) <= src.size(d).
- For each dimension d, if d!= dim, index.size(d) <= self.size(d).
- The value range of dim is [–self.dim(), self.dim() – 1].
Example:
Input tensor , Index tensor , dim = 1, Source tensor , Output tensor
dim = 1 indicates that scatter_add accumulates values along the columns of the tensor according to .
= 1 + 10,
= 2 + 12,
= 3 + 11,
= 4 + 13 + 14,
= 5 + 15,
= 6,
= 7,
= 8,
= 9.
The number of dimensions of , , and are all 2. The size of each dimension of {2, 3} is not greater than the corresponding dimension size {2, 3} of . On the dimension dim!= 1 (dim = 0), the dimension size {2} of is not greater than the corresponding dimension size {3} of . The maximum value {2} in is less than the size {3} of in the dim = 1 dimension.
Each operator has calls. First, aclnnScatterAddGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnScatterAdd is called to perform computation.
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]
- Deterministic compute:
- aclnnScatterAdd defaults to a deterministic implementation.
The following example is for reference only. For details, see .