- Description: Performs the addition operation and activates the result.
- Formula:
aclnnAddRelu and aclnnInplaceAddRelu implement the same function. The differences are as follows. Select a proper operator based on the actual scenario.
- aclnnAddRelu: You need to create an output tensor object to store the computation result.
- aclnnInplaceAddRelu: You do not need to create an output tensor object. The computation result is stored in the memory of the input tensor.
Each operator has calls. First, aclnnAddReluGetWorkspaceSize or aclnnInplaceAddReluGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnAddRelu or aclnnInplaceAddRelu is called to perform computation.
[object Object][object Object][object Object][object Object]
Parameters:
self (aclTensor*, compute input): input
[object Object]in the formula, which is an aclTensor on the device and indicates the target tensor to be converted. The data type must meet the with other. The shape must meet the with other. are supported. The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, INT8, UINT8, INT16, INT32, or INT64.
- [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, INT8, UINT8, INT16, INT32, or INT64.
other (aclTensor*, compute input): input
[object Object]in the formula. The data type must meet the with self. The shape must meet the with self. are supported. The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, INT8, UINT8, INT16, INT32, or INT64.
- [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, INT8, UINT8, INT16, INT32, or INT64.
alpha (aclScalar*, compute input):
[object Object]in the formula. The data type can be converted to the data type deduced from self and other.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, INT8, UINT8, INT16, INT32, or INT64.
- [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, INT8, UINT8, INT16, INT32, or INT64.
out (aclTensor*, compute output):
[object Object]in the formula. The data type must be convertible to the data type deduced from self and other, and the shape must be the shape after self and other are broadcast. are supported. The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, INT8, UINT8, INT16, INT32, or INT64.
- [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, INT8, UINT8, INT16, INT32, or INT64.
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): workspace size allocated on the device, which is obtained by the first-phase API aclnnAddReluGetWorkspaceSize.
- executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
- stream (aclrtStream, input): stream for executing the task.
Returns:
Parameters:
selfRef (aclTensor*, compute input|compute output): input and output tensors, that is, self and out in the formula. They are aclTensors on the device and indicate the target tensors to be converted. Its data type and the data type of other must meet the type deduction rules (see ) and must be the data type that can be converted after deduction. are supported. The can be ND.
- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, INT8, UINT8, INT16, INT32, or INT64.
- [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, INT8, UINT8, INT16, INT32, or INT64.
other (aclTensor*, compute input): input
[object Object]in the formula. The data type must meet the with selfRef. The shape must meet the with selfRef. are supported. The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, INT8, UINT8, INT16, INT32, or INT64.
- [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, INT8, UINT8, INT16, INT32, or INT64.
alpha (aclScalar*, compute input):
[object Object]in the formula. The data type can be converted to the data type deduced from selfRef and other.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16, FLOAT32, INT8, UINT8, INT16, INT32, or INT64.
- [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, INT8, UINT8, INT16, INT32, or INT64.
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): workspace size allocated on the device, which is obtained by the first-phase API aclnnInplaceAddReluGetWorkspaceSize.
executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
stream (aclrtStream, input): stream for executing the task.
Returns:
Deterministic compute:
- aclnnAddRelu&aclnnInplaceAddRelu defaults to a deterministic implementation.
For the scenario where the data type of selfRef is INT8 and that of other is INT32: The cast operator has a precision issue when converting the INT32 type to the INT8 type (see . In this scenario, the output result precision cannot be ensured.
The following example is for reference only. For details, see .