Cortex-M: fix quantized_linear bias on non-MVE targets#20045
Conversation
The AOT linear lowering folded the bias into the precomputed kernel_sum and passed None as the kernel's bias argument. The CMSIS-NN fully-connected kernel only reads kernel_sum on the MVE path; the DSP and scalar paths ignore kernel_sum and read the bias argument directly, so on those targets the bias was silently dropped and biased linears produced incorrect results. Pass the int32 bias node through to the kernel in addition to folding it into kernel_sum. On any given build only one ISA path executes, so the bias is applied exactly once: MVE via kernel_sum, DSP/scalar via the bias argument. Verified on the Corstone-300 FVP for cortex-m0plus. Authored with Claude Code.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20045
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit 6030050 with merge base 4c9c444 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
AdrianLundell
left a comment
There was a problem hiding this comment.
I would suggest that we set kernel_sum to None when bias is used and vice versa to not waste memory, what do you say?
Yes, absolutely. So much so I already did it in #19676 2 weeks ago. I'll close this one in favor of that one. 🙃 |
Summary
The AOT linear lowering folded the bias into the precomputed kernel_sum and passed None as the kernel's bias argument. The CMSIS-NN fully-connected kernel only reads kernel_sum on the MVE path; the DSP and scalar paths ignore kernel_sum and read the bias argument directly, so on those targets the bias was silently dropped and biased linears produced incorrect results.
Pass the int32 bias node through to the kernel in addition to folding it into kernel_sum. On any given build only one ISA path executes, so the bias is applied exactly once: MVE via kernel_sum, DSP/scalar via the bias argument.
Test Plan
Verified on the Corstone-300 FVP for cortex-m0plus.
Authored with Claude Code.