Fix optimized binary op broadcast rank mismatch (#21052)
### Summary The optimized last-dimension and planned broadcast paths resize `out` to one input's shape after the operator has already selected the broadcast target. When leading dimensions of size one make the target rank larger, that second resize tries to change the immutable rank and fails at runtime. Resize `out` to the broadcast target in both paths and add regression coverage for add and mul in both argument orders. Fixes #10959 ### Test plan `./cmake-out/kernels/test/optimized_kernels_test --gtest_brief=1` `lintrunner kernels/optimized/cpu/binary_ops.cpp kernels/optimized/cpu/binary_ops.h kernels/test/op_add_test.cpp kernels/test/op_mul_test.cpp` cc @larryliu0820 @manuelcandales
M
Maya Bennett committed
1a770b86acb8b2817d51862f898657ad0840334d
Parent: c48a7b2
Committed by GitHub <noreply@github.com>
on 7/27/2026, 3:18:43 PM