Summary
The previous sections have detailed some tips for locating and solving accuracy problems of TBE operators. You can perform the following steps to solve any accuracy problem:
- Exclude problems caused by accuracy-irrelevant reasons such as incorrect comparison data, formulas, and CCE generation.
- Cast the data type to check the calculation error caused by the low-precision type float16.
- Determine the unqualified range based on the distribution of unqualified accuracy data. You can use tools such as Excel and Octave to visualize the distribution.
- View the intermediate result, analyze the computation process, and find the root cause (such as instruction problems, overflows, and calculation failures).
- Adopt specific solutions for specific causes.
- Check whether the mathematical formula used in the simulation analysis can fit the actual value and whether the theoretical relative error meets the requirements. If the solution has accuracy problems, optimize the solution by following the instructions described in Mathematical Formula Optimization.
- If the accuracy of the solution meets the requirement theoretically, and the problem is caused by the instruction accuracy, optimize the solution by following the instructions described in Instruction Accuracy Optimization.
- For an overflow error (commonplace for functions such as
and
), use a transform formula, for example,
. - For a calculation failure, that is, the error is gradually amplified as the increase of the calculation times. Especially when a coefficient or the input
is excessively large, the error amplification factor will be far greater than 1, leading to divergence of the final result. This may be avoided by formula replacement or range mapping.
Parent topic: TBE Operator Accuracy Tuning