FilesLast commitLast update
23 days ago
4 months ago
2 months ago
6 months ago
22 days ago
2 months ago
2 months ago
22 days ago
1 month ago
17 days ago
README

QuantMax

English | 简体中文

Applicable Products

Product Support
Ascend 950PR&950DT products √
Atlas A3 products ×
Atlas A2 products ×
Atlas 200I/500 A2 inference products ×
Atlas inference products ×
Atlas training products ×

Function

  • Operator function: quantizes input x according to the input scale, and computes the maximum value amax of the absolute value of input x.

  • Formula:

    y=Cast(x×scale,dst_type,round_mode)y = \text{Cast}(x \times scale, \text{dst\_type}, \text{round\_mode})

    amax=max⁡(∣x∣)amax = \max(|x|)

    where xx denotes the input tensor, scalescale denotes the quantization scaling factor, dst_type\text{dst\_type} specifies the output type, round_mode\text{round\_mode} specifies the rounding mode, and amaxamax is the maximum value of the absolute values of all elements of the input tensor.

Parameters

Parameter name Input/Output/Attribute Description Data type Data format
x Input Input tensor to be quantized, corresponding to x in the formula. Any shape of 1-8 dimensions is supported. FLOAT, FLOAT16, BFLOAT16 ND
scale Input Quantization scaling factor, corresponding to scale in the formula. The shape is fixed to [1]. FLOAT ND
y Output Quantized output tensor, corresponding to y in the formula. Its shape is the same as x, and its data type is determined by dst_type. HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3 ND
amax Output Maximum value of the absolute value of x, corresponding to amax in the formula. The shape is fixed to [1], and the data type is the same as x. FLOAT, FLOAT16, BFLOAT16 ND
round_mode Attribute The value must be a valid rounding mode supported by the Cast API. string -
dst_type Attribute Specifies the output quantization data type. 34=HIFLOAT8, 35=FLOAT8_E5M2, 36=FLOAT8_E4M3. int -

Constraints

  • Matching relationship between round_mode and dst_dtype:
    • When dst_dtype is 35 or 36, round_mode must be "rint".
    • When dst_dtype is 34, round_mode must be "round" or "hybrid".

Invocation Description

Invocation method Invocation sample Description
aclnn invocation test_aclnn_quant_max Invokes the QuantMax operator through the aclnnQuantMax interface.
Graph-mode invocation - Invokes the QuantMax operator through the operator IR graph construction method.