[object Object]

[object Object][object Object]undefined
[object Object]
  • 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 {{Vi}i=132}\{\{V_i\}_{i=1}^{32}\} is quantized into {mxscale1,{Pi}i=132}\{mxscale1, \{P_i\}_{i=1}^{32}\}.

      shared_exp=floor(log2(maxi(Vi)))emaxshared\_exp = floor(log_2(max_i(|V_i|))) - emax mxscale1=2shared_expmxscale1 = 2^{shared\_exp} Pi=cast_to_dst_type(Vi/mxscale1,round_mode), i from 1 to 32P_i = cast\_to\_dst\_type(V_i/mxscale1, round\_mode), \space i\space from\space 1\space to\space 32
    • In addition, the input x is grouped into 32 groups along the -2 axis, and a group of 32 numbers {{Vj}j=132}\{\{V_j\}_{j=1}^{32}\} is quantized into {mxscale2,{Pj}j=132}\{mxscale2, \{P_j\}_{j=1}^{32}\}.

      shared_exp=floor(log2(maxj(Vj)))emaxshared\_exp = floor(log_2(max_j(|V_j|))) - emax mxscale2=2shared_expmxscale2 = 2^{shared\_exp} Pj=cast_to_dst_type(Vj/mxscale2,round_mode), j from 1 to 32P_j = cast\_to\_dst\_type(V_j/mxscale2, round\_mode), \space j\space from\space 1\space to\space 32
    • -The quantized PiP_{i} on axis 1 is used to form the output y1Out according to the position of the corresponding ViV_{i}, and the mxscale1 is used to form the output mxscale1Out according to the group on the corresponding -1 axis. The quantized PjP_{j} on axis -2 is used to form the output y2Out according to the position of the corresponding VjV_{j}, 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
[object Object]

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.

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

    [object Object]
  • Returns

    [object Object]: status code. For details, see .

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

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

[object Object]