Repository navigation
Conversation
|
@pytorchbot label "release notes: ops & kernels" |
There was a problem hiding this comment.
🟡 Changes recommended
The portable and optimized division helpers write broadcast results sequentially rather than using output strides, permuting results for channels-last tensors and requiring a stride-aware fix with regression coverage.
1 open issue
What changed in this PR
This PR addresses the complex division broadcasting bug from #24408 in ExecuTorch’s portable and optimized CPU kernels.
Changes:
- Replace direct input indexing with the shared binary elementwise broadcasting helper.
- Require matching complex input and output dtypes before typed data access.
- Add complex64/128 regression tests for scalar and multidimensional broadcasting, empty tensors, and dtype mismatches.
| File | Description |
|---|---|
kernels/test/op_div_test.cpp |
Adds complex broadcasting and dtype-rejection tests. |
kernels/portable/cpu/op_div.cpp |
Uses the broadcasting helper and validates complex dtypes. |
kernels/optimized/cpu/op_div.cpp |
Applies the same changes to optimized complex division. |
Review effort: Balanced
614b52b to
3d24ca9
Compare
3d24ca9 to
01f6068
Compare
01f6068 to
acadf9b
Compare
acadf9b to
9241ec6
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The shared helper unconditionally disables the no-broadcast fast path, adding unnecessary axis traversal for equal-shaped contiguous operands and losing sequential memory access for equal-shaped channels-last tensors.
1 open issue
1 resolved since last review
Review effort: Balanced
050b241 to
fb256ec
Compare
|
@mshr-h is this ready for review? it is marked draft and WIP |
|
@JakeStevens thanks for checking. it's not ready for review. i'll ping you when it's ready. |
fb256ec to
21a37dd
Compare
Use broadcast-aware indexing for complex div in optimized and portable CPU kernels, and require matching complex input and output dtypes. Respect output strides while preserving linear iteration for matching dense layouts. Cover scalar and channels-last broadcasting, mixed ranks, empty tensors, bounded output resizing, and invalid inputs. Refs pytorch#24408
21a37dd to
3e058da
Compare
Consume source values in logical output order for channels-last tensors while preserving the default-layout fast path. Add regression tests for matching shapes, mixed ranks, mask broadcasting, and insufficient sources. Include masked_scatter tests in the CMake suite.
3e058da to
06aa91e
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…rage for masked scatter stride remapping' Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>


Summary
Refs #24408
The optimized and portable complex div kernels index both inputs using the output index. When an operand is broadcast, this can read past its buffer and produce incorrect results.
Use
apply_binary_elementwise_fnto handle broadcasting, and require matching input/output dtypes before accessing typed data.Add regression tests for complex64/128 covering scalar operands on either side, multidimensional broadcasting, empty tensors, and mismatched dtypes.
Test plan
Run the div tests in both CPU configurations:
Result: 34 optimized CPU tests and 38 portable CPU tests passed.