[object Object]

[object Object][object Object]undefined
[object Object]
  • 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 E[x]=xˉE[x] = \bar{x} indicates the mean value of xx, and Var[x]=1ni=1n(xiE[x])2Var[x] = \frac{1}{n} * \sum_{i=1}^n(x_i - E[x])^2 indicates the variance of xx. Then:

      {yOut=xE[x]Var[x]+epsγ+βmeanOut=E[x]rstdOut=1Var[x]+eps\left\{ \begin{array} {rcl} yOut& &= \frac{x - E[x]}{\sqrt{Var[x] + eps}} * \gamma + \beta \\ meanOut& &= E[x]\\ rstdOut& &= \frac{1}{\sqrt{Var[x] + eps}}\\ \end{array} \right.
    • Swish:

      yOut=x1+escalexyOut = \frac{x}{1+e^{-scale * x}}

      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.

[object Object]

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]
[object Object]
  • Parameters:

    • x (aclTensor*, computation input): target tensor to be group normalized, xx 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, γ\gamma 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 xx. 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, β\beta 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 xx. 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 xx 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): epseps 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): scalescale 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 xx. 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 gammagamma. The shape is [object Object], where [object Object] indicates the size of the 0th dimension of xx, and [object Object] is the computation input, indicating that the first dimension of the input xx 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 gammagamma. The shape is [object Object], where [object Object] indicates the size of the 0th dimension of xx, and [object Object] indicates the computation input, indicating that the first dimension of the input xx 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.
  • Returns:

    aclnnStatus: status code. For details, see .

[object Object]
[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:

    aclnnStatus: status code. For details, see .

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

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

[object Object]