cpu: riscv: softmax: add f16 support #4491
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for FP16 (half-precision) data type to the RISC-V Vector (RVV) Softmax primitive.
Added compute_softmax_f16_rvv which utilizes Zvfh intrinsics. To ensure precision, the kernel performs accumulation and exponential/logarithm calculations in f32 (using widening conversions __riscv_vfwcvt) and converts back to f16 for the final output.
Checklist
General
make testandmake test_benchdnn_*) pass locally for each commit?Performance improvements
Performance was evaluated on SG2044 (RISC-V) using 16 cores (pinned). The comparison is between the new RVV f16 implementation and the previous behavior (fallback to reference).
(Note: Only collected FWD_D cases)
speedup_ratio.csv
with_f16_softmax.csv
without_f16_softmax.csv
Average Speedup: ~23.40x