--allow_hf32

Applicable Products

  • Ascend 950PR/Ascend 950DT: supported
  • Atlas A3 training products/Atlas A3 inference products: supported
  • Atlas A2 training products/Atlas A2 inference products: supported
  • Atlas 200I/500 A2 inference products: not supported
  • Atlas inference products: not supported
  • Atlas training products: not supported
  • IPV350: not supported

Description

This option is reserved and is not supported in the current version.

Enables the function of automatically replacing the float32 data type with the HF32 data type. In the current version, this option takes effect only for Conv and Matmul operators.

HF32 is a single-precision floating-point type of Ascend for internal computation of operators. The following figure shows the comparison of HF32 with other common data types. HF32 shares the same value range with float32, but its mantissa precision (11 bits) is close to FP16 (10 bits). Replacing the original float32 single-precision data type with the HF32 single-precision data type by precision reduction can greatly reduce the space occupied by data and achieve performance improvement.
Figure 1 Comparison of HF32 with other data types

See Also

  • For the same operator, if enable_hi_float_32_execution or enable_float_32_execution is configured using --op_precision_mode, you are not advised using this option together with --allow_hf32. If they are used together, the priority is as follows:

    op_precision_mode(ByNodeName) > allow_hf32 > op_precision_mode(ByOpType)

  • --allow_hf32 automatically replaces float32 with HF32. To make this parameter take effect, ensure that the input or output type of the involved operator is float32. The default value of --precision_mode_v2 is fp16. If the operator type in the original network model is float32, it will be forcibly converted to float16. In this case, --allow_hf32 does not take effect. You are advised to change the value of --precision_mode_v2 to origin. The default value of --precision_mode is force_fp16, and you are advised to change the value to must_keep_origin_dtype or force_fp32.

Arguments

Argument:

  • true: Enables automatic conversion from FP32 to HF32 for Conv and Matmul operators.

    For details about the involved operators, see the opp/built-in/op_impl/ai_core/tbe/impl_mode/allow_hf32_matmul_t_conv_t.ini file under the CANN installation directory. This file cannot be modified by users.

  • false: Disables automatic conversion from FP32 to HF32 for Conv and Matmul operators.

    For details about the involved operators, see the opp/built-in/op_impl/ai_core/tbe/impl_mode/allow_hf32_matmul_f_conv_f.ini file under the CANN installation directory. This file cannot be modified by users.

Default: For Conv operators, FP32-to-HF32 conversion is enabled by default. For Matmul operators, this conversion is disabled by default.

Suggestions and Benefits

None

Example

--allow_hf32=true

If ge.exec.allow_hf32 can be found in the model conversion log, the parameter settings are effective.

Dependencies and Restrictions

None