Function: performs MX quantization on the -1 and -2 axes, with the destination data type being FLOAT4 or FLOAT8. On the given -1 and -2 axes, the quantization scales mxscale1 and mxscale2 corresponding to the two groups of numbers are calculated every 32 numbers, and are used as the corresponding parts of the output mxscale1Out and mxscale2Out. Then, all elements in the two groups of numbers are divided by the corresponding mxscale1 or mxscale2, and converted to the corresponding dstType based on the round_mode to obtain the quantization results y1 and y2, which are used as the corresponding parts of the output y1Out and y2Out.
Formulas:
Currently, only scaleAlg=0 is supported, that is, the OCP implementation is as follows:
The input x is grouped into 32 numbers along the -1 axis. A group of 32 numbers is quantized into .
In addition, the input x is grouped into 32 groups along the -2 axis, and a group of 32 numbers is quantized into .
-The quantized on axis 1 is used to form the output y1Out according to the position of the corresponding , and the mxscale1 is used to form the output mxscale1Out according to the group on the corresponding -1 axis. The quantized on axis -2 is used to form the output y2Out according to the position of the corresponding , and the mxscale2 is used to form the output mxscale2Out according to the group on the corresponding -2 axis.
emax: exponent bit of the maximum regular number of the corresponding data type.
[object Object]undefined
Each operator has [object Object]two-phase API calls[object Object]. You must call aclnnDynamicMxQuantWithDualAxisGetWorkspaceSize to obtain the workspace size required for computation and the executor that contains the operator computation process, and then call aclnnDynamicMxQuantWithDualAxis to perform the computation.
Parameters
[object Object]Return Value
[object Object]: status code. For details, see .The first-phase API implements input parameter validation. The following error codes may be returned.
[object Object]
- The restrictions on the shapes of x, mxscale1Out, and mxscale2Out are as follows:
- rank(mxscale1Out) = rank(x) + 1.
- rank(mxscale2Out) = rank(x) + 1.
- mxscale1Out.shape[-2] = (ceil(x.shape[-1] / 32) + 2 - 1) / 2.
- mxscale2Out.shape[-3] = (ceil(x.shape[-2] / 32) + 2 - 1) / 2.
- mxscale1Out.shape[-1] = 2.
- mxscale2Out.shape[-1] = 2.
- Other dimensions are the same as those of the input x.
- For example, if the shape of the input x is [B, M, N] and the destination data type is FP8, the shapes of y1 and y2 are [B, M, N], the shape of mxscale1 is [B, M, (ceil(N/32)+2-1)/2, 2], and the shape of mxscale2 is [B, (ceil(M/32)+2-1)/2, N, 2].
- Deterministic description: The default deterministic implementation of aclnnDynamicMxQuantWithDualAxis is used.
The following example is for reference only. For details, see .