You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2dacff2
Browse filesBrowse the repository at this point in the historyBrowse files
Swap reverse-broadcast operands once in handle_broadcast_elementwise (#24809)
### Summary
On the `*ReverseArguments` paths, `handle_broadcast_elementwise` hands
the broadcasting maps `(b, a)`, so every non-commutative caller had to
pass a hand-swapped lambda on those paths. `op_div` and
`op_add_sub_impl` did, `op_le` did not (#24485). This swaps `vec_fun`'s
arguments once inside `handle_broadcast_elementwise`, so the lambda
always receives `(a, b)`, and removes the per-op swaps, resolving the
TODO in `op_add_sub_impl.h`.
`op_mul` is commutative, so it passes `kCommutative = true` to skip
compiling the swapped copy, which would otherwise add about 16 KB to
`op_mul`. With it, `op_mul` is unchanged and
`op_div`/`op_add`/`op_sub`/`op_le` shrink slightly.
Stacked on #24486, whose tests cover `le` on all three reverse paths;
land after it.
Authored with AI assistance (Claude Code).
### Test plan
`optimized_kernels_test` passes (1839 tests, unchanged). With the
central swap disabled, 9 add/sub/div/le tests fail, so the existing
tests cover the swap for every non-commutative caller.
---------
Co-authored-by: SofianElmotiem <sofianelmotiem@gmail.com>
0 commit comments