API function: Adds dequant and quant operations before and after the Swish gating linear unit activation function to implement the DequantSwigluQuant computation of x. Compared with , this API has two types of new parameters: (1) Three input parameters used by the Ascend 950 chip are added: dstType, roundModeOptional, and activateDim. (2) On the Atlas A2 and Atlas A3 chips, four parameters are added for the variant SwiGLU used by GPT-OSS: swigluMode, clampLimit, gluAlpha, and gluBias. When this API is used on the Ascend 950 chip, default values need to be set for these four parameters. Select the appropriate API as required.
The formula for swigluMode = 0 is as follows:
where A[object Object]i[object Object] indicates the first half of dequantOut[object Object]i[object Object], and B[object Object]i[object Object] indicates the second half of dequantOut[object Object]i[object Object].
The formula for swigluMode = 1 is as follows:
x_glu indicates the even-indexed part of dequantOut[object Object]i[object Object], and x_linear indicates the odd-indexed part of dequantOut[object Object]i[object Object].
Each operator has [object Object]two-phase API calls[object Object]. You must call aclnnDequantSwigluQuantV2GetWorkspaceSize to obtain the workspace size required for computation and the executor that contains the operator computation process, and then call aclnnDequantSwigluQuantV2 to perform the computation.
Parameters
[object Object]Returns
[object Object]: status code. For details, see .The first-phase API implements input parameter validation. The following error codes may be returned.
[object Object]
Deterministic computation:
- The default deterministic implementation of aclnnDequantSwigluQuantV2 is used.
The dimension of activateDim corresponding to the input x must be a multiple of 2, and the number of dimensions of x must be greater than 1.
If the data type of the input x is INT32, weightScaleOptional cannot be null. If the data type of the input x is not INT32, weightScaleOptional cannot be input; a null pointer must be passed.
If the data type of the input x is not INT32, activationScaleOptional cannot be input and a null pointer is passed.
If the data type of the input x is not INT32, biasOptional cannot be input and a null pointer is passed.
When the output data type of yOut is FLOAT4_E2M1 or FLOAT4_E1M2, the last dimension of yOut must be a multiple of 2.
If the dimension corresponding to activateDim is not the last axis of x, the last axis of the output yOut cannot exceed 5120.
The sum of all elements in groupIndexOptional cannot be greater than the product of the remaining axes of the input x except the last axis.
The parts of the output yOut and scaleOut that exceed the sum of all elements in groupIndexOptional are not cleared. The memory of this part is junk data.
[object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: When groupIndexOptional is input, the maximum size of the input tensor supported by the operator is limited. The last axis of x cannot exceed 7232.
The following example is for reference only. For details, see .