Repository navigation
Fix arm_softmax_s16 normalization and output saturation - #249
Conversation
mansnils
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Could you leave the Arm copyright years, as it is given you are not Arm employee?
|
Thank you and sorry for the delay. Can you make datasets reproducible through existing generators and TFL/TFLM reference kernels following unit test conventions (Tests/UnitTest/README.md:147)? |
Replace the hand-written boundary arrays in test_arm_softmax_s16.c with three generated test sets. SoftmaxSettings takes an optional input_data argument so a set can use fixed inputs; the expected outputs come from the TFL reference kernel, and a rerun of the generator gives identical headers. - softmax_s16_sum_boundary: one row whose exp sum is 262142, the largest sum whose normalized reciprocal input still fits in int16, and one at 262143, where the normalization overflowed before this fix. - softmax_s16_equal_inputs: two equal inputs, each output exactly one half. - softmax_s16_single_input: one input, the output saturates at INT16_MAX.
|
@mansnils Done: the hand-written arrays are replaced by three softmax s16 sets from generate_test_data.py with fixed inputs (a rerun gives identical headers), and the expected outputs come from the TFL reference kernel. sum_boundary puts the exp sum just below and exactly at the point where the old normalization overflowed, and equal_inputs and single_input cover the other two cases. The old kernel fails the overflow row and the single-input set, and the fixed one passes all softmax s16 sets. I added an optional input_data argument to SoftmaxSettings for the fixed inputs; happy to move it if you'd prefer another place. |
arm_softmax_s16could double outputs at a normalization boundary and wrap a one-class result. We use unsigned normalization arithmetic and clamp the reciprocal input and final output. The regression and all softmax Unity tests pass with the normal Release CMake build.Fixes #248
— ChipLab