SetHF32
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function
Sets whether to enable the HF32 mode (data type that can be used for matrix multiplication) in Cube-only mode (only matrix computation). After the mode is enabled, the float32 data type is converted to the hf32 data type during matrix multiplication, which improves the computing performance but causes precision loss.
Prototype
1 | __aicore__ inline void SetHF32(bool enableHF32 = false, int32_t transMode = 0) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
enableHF32 |
Input |
Whether to enable the HF32 mode. The default value is false, indicating that the HF32 mode is disabled. |
transMode |
Input |
ROUND mode used for converting float to hf32 when the HF32 mode is enabled. The default value is 0. 0: rounding to the nearest even number when the distance is equal. 1: rounding to the nearest number away from zero when the distance is equal. |
Returns
None
Restrictions
This API can be called only in Cube-only mode.
Example
1 2 3 4 5 6 7 8 9 | // Cube-only mode #define ASCENDC_CUBE_ONLY REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling); // A/B/C/BIAS is of the float type. mm.SetTensorA(gm_a); mm.SetTensorB(gm_b); mm.SetBias(gm_bias); mm.SetHF32(true); mm.IterateAll(gm_c); mm.SetHF32(false); |