Description: Adds values from the src tensor into the self tensor in sequence according to the specified axis direction and the corresponding position specified by the index tensor. If more than one src value is written at the same position in self, these values are accumulated at this position. For a three-dimensional tensor, self is updated based on 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, there is index.size(d) <= src.size(d).
- For each dimension d, if d!= dim, there is 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.
[object Object][object Object]
Parameters:
self (aclTensor*, compute input): input
[object Object]in the formula, aclTensor on the device. It indicates the target tensor of scatter. The shape supports zero to eight dimensions, and the number of dimensions must be the same as those of index and src. The data type is the same as that of src. are supported. The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, DOUBLE, INT64, INT32, INT16, INT8, UINT8, BOOL, COMPLEX64, or COMPLEX128.
- [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 BFLOAT16, FLOAT16, FLOAT32, DOUBLE, INT64, INT32, INT16, INT8, UINT8, BOOL, COMPLEX64, or COMPLEX128.
dim (int64_t, compute input):
[object Object]in the formula. The data type is INT64.index (aclTensor*, compute input): input
[object Object]in the formula, aclTensor on the device. The data type can be INT32 or INT64. The number of dimensions of index must be the same as that of src. are supported. The can be ND.src (aclTensor*, compute input): input
[object Object]in the formula, aclTensor on the device. It indicates the source tensor. The number of dimensions of src must be the same as that of index. The data type must be the same as that of self. The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, DOUBLE, INT64, INT32, INT16, INT8, UINT8, BOOL, COMPLEX64, or COMPLEX128.
- [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 BFLOAT16, FLOAT16, FLOAT32, DOUBLE, INT64, INT32, INT16, INT8, UINT8, BOOL, COMPLEX64, or COMPLEX128.
out (aclTensor*, compute output):
[object Object]in the formula, aclTensor on the device. The shape must be the same as that of self. The data type must be the same as that of self. The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, DOUBLE, INT64, INT32, INT16, INT8, UINT8, BOOL, COMPLEX64, or COMPLEX128.
- [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 BFLOAT16, FLOAT16, FLOAT32, DOUBLE, INT64, INT32, INT16, INT8, UINT8, BOOL, 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 process.
Returns:
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 the first-phase API aclnnScatterAddGetWorkspaceSize.
executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
stream (aclrtStream, input): stream for executing the task.
Returns:
- Deterministic compute:
- aclnnScatterAdd defaults to a deterministic implementation.
The following example is for reference only. For details, see .