- Description: Computes the group normalization result out, mean value meanOut, reciprocal rstdOut of the standard deviation, and Swish output of the input x.
- Formula:
GroupNorm: Assume indicates the mean value of , and indicates the variance of . Then:
Swish:
When activateSwish is set to True, Swish is computed. In this case, x in the Swish formula is out obtained by using the GroupNorm formula.
Each operator has calls. First, aclnnGroupNormSwishGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnGroupNormSwish is called to perform computation.
[object Object][object Object]
Parameters:
- x (aclTensor*, computation input): target tensor to be group normalized, in the
[object Object]computation formula, and aclTensor on the device. The shape must be greater than 1D. The 0th and 1st dimensions of x must be greater than 0, and the 1st dimension must be exactly divided by group. The data type can be FLOAT32, FLOAT16, or BFLOAT16. The can be ND. are supported. - gamma (aclTensor*, computation input): gamma parameter in group normalization, in the
[object Object]computation formula, and aclTensor on the device. The shape is 1D. The number of elements must be the same as that of the 1st dimension of the input . The data type of gamma must be the same as that of beta, which must be FLOAT or the same as that of x. The data type can be FLOAT32, FLOAT16, or BFLOAT16. The can be ND. are supported. - beta (aclTensor*, computation input): beta parameter in group normalization, in the
[object Object]computation formula, and aclTensor on the device. The shape is 1D. The number of elements must be the same as that of the 1st dimension of the input . The data type of gamma must be the same as that of beta, which must be FLOAT or the same as that of x. The data type can be FLOAT32, FLOAT16, or BFLOAT16. The can be ND. are supported. - numGroups (int64_t, computation input): integer on the host, indicating that the first dimension of the input is divided into groups. The value is greater than 0.
- dataFormatOptional (char*, computation input): character type on the host, indicating the data format. Only NCHW is supported in the current version.
- eps (double, computation input): in the
[object Object]and[object Object]computation formulas, used to prevent the offset of dividing by 0. The value is greater than 0. It is of the DOUBLE type on the host. - activateSwish (bool, computation input): indicates whether to support Swish computation. If this parameter is set to true, Swish computation is performed after groupnorm computation. It is of the BOOL type on the host.
- swishScale (double, computation input): of Swish computation. It is of the DOUBLE type on the host.
- yOut (aclTensor*, computation output): group normalization result and aclTensor on the device. The data type and shape are the same as those of . The data type can be FLOAT32, FLOAT16, or BFLOAT16. The can be ND. are supported.
- meanOut (aclTensor*, computation output): mean value after x is grouped and aclTensor on the device. The data type is the same as that of . The shape is
[object Object], where[object Object]indicates the size of the 0th dimension of , and[object Object]is the computation input, indicating that the first dimension of the input is divided into groups. The data type can be FLOAT32, FLOAT16, or BFLOAT16. The can be ND. are supported. - rstdOut (aclTensor*, computation output): reciprocal of the standard deviation after x is grouped and aclTensor is on the device. The data type is the same as that of . The shape is
[object Object], where[object Object]indicates the size of the 0th dimension of , and[object Object]indicates the computation input, indicating that the first dimension of the input is divided into groups. The data type can be FLOAT32, FLOAT16, or BFLOAT16. The can be ND. are supported. - workspaceSize (uint64_t*, output): size of the workspace to be allocated on the device.
- executor (aclOpExecutor **, output): operator executor, containing the operator computation process.
- x (aclTensor*, computation input): target tensor to be group normalized, in the
Returns:
[object Object]
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 calling the first-phase API aclnnGroupNormSwishGetWorkspaceSize.
- executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
- stream (aclrtStream, input): stream for executing the task.
Returns:
- Deterministic computation
- aclnnGroupNormSwish defaults to a deterministic implementation.
The following example is for reference only. For details, see .
[object Object]