Commit 2ac5836
Fix sign-compare errors in quantized cpu kernels for Zephyr/GCC builds
Summary:
## Why?
The Zephyr firmware target `tycho_t3c-tsn_graph_simulator_mps3_an547_cmake` failed
to compile `xplat/executorch/kernels/quantized/cpu/embeddingxb.cpp` under
`-Werror=sign-compare`. The loop variable was declared `size_t` (unsigned) but
compared against `Tensor::dim()`, which returns `ssize_t` (signed). On 64-bit
host toolchains the warning is often suppressed or both types match in width, so
the regression slipped in via D90402567 (int32 indices support). On the 32-bit
Zephyr ARM target the mismatch is fatal. Several sibling kernels in the same
directory have the identical latent pattern and would break the moment they get
pulled into a Zephyr build path.
## What?
Match the loop variable's type to the signed return type of `Tensor::dim()` by
switching `size_t` to `ssize_t` everywhere this pattern appears in the quantized
cpu kernels and two test files. This is also the safer pattern — casting to
`size_t` would turn a negative `dim()` into `SIZE_MAX` and overflow the
fixed-size stack buffer used for sizes. The change is mirrored across the
xplat and fbcode copies so the diff_train sync stays consistent.
Differential Revision: D1057015881 parent 1d754c8 commit 2ac5836
6 files changed
Lines changed: 6 additions & 6 deletions
File tree
- kernels
- quantized/cpu
- test
- custom_kernel_example
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
| 227 | + | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
| 593 | + | |
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
645 | | - | |
| 645 | + | |
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| |||
0 commit comments