Uh oh!
There was an error while loading. Please reload this page.
Add bitwise left/right - #15893
Conversation
mergennachin
commented
Nov 19, 2025
@mergennachin has imported this pull request. If you are a Meta employee, you can view this in D87451202. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for bitwise left shift (<<) and right shift (>>) operations to the ExecutorTorch portable kernel library, following the existing pattern for bitwise operations (and, or, xor).
Key Changes:
- Implementation of
bitwise_left_shiftandbitwise_right_shiftoperators with both Tensor and Scalar variants - Comprehensive test coverage for both operations including edge cases (zero shift, different data types)
- Build system integration across Buck (bzl), CMake, and YAML configuration files
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl | Adds Buck build targets for the new shift operators (ordering needs correction) |
kernels/test/targets.bzl | Registers test targets for both shift operations (correctly ordered) |
kernels/test/CMakeLists.txt | Adds test source files to CMake build (correctly ordered) |
kernels/portable/functions.yaml | Defines kernel function signatures (should use - op: instead of - func:) |
kernels/portable/cpu/pattern/bitwise_op.h | Adds shift operation functors and templates (contains redundant code) |
kernels/portable/cpu/op_bitwise_left_shift.cpp | Implements left shift operation using the bitwise pattern |
kernels/portable/cpu/op_bitwise_right_shift.cpp | Implements right shift operation using the bitwise pattern |
kernels/test/op_bitwise_left_shift_test.cpp | Provides comprehensive test coverage for left shift |
kernels/test/op_bitwise_right_shift_test.cpp | Provides comprehensive test coverage for right shift |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/15893
Note: Links to docs will display an error until the docs builds have been completed. ⏳ 28 Pending, 2 Unrelated FailuresAs of commit c1ad491 with merge base 62dccf1 ( FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Summary: Pull Request resolved: #15893 Differential Revision: D87451202 Pulled By: mergennachin
6861b0a to
8c43463Compare@mergennachin has exported this pull request. If you are a Meta employee, you can view the originating Diff in D87451202. |
Summary: Pull Request resolved: #15893 Differential Revision: D87451202 Pulled By: mergennachin
8c43463 to
11c1364CompareThere was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary: Did not add as core aten op. But used "func" and enabled exporting via: ``` to_edge_transform_and_lower( exported_program, partitioner=None, compile_config=EdgeCompileConfig( _core_aten_ops_exception_list=[ torch.ops.aten.bitwise_left_shift.Tensor, torch.ops.aten.bitwise_left_shift.Tensor_Scalar, torch.ops.aten.bitwise_right_shift.Tensor, torch.ops.aten.bitwise_right_shift.Tensor_Scalar, ] ), ) ``` In the future, we may promote to core aten op. Differential Revision: D87451202 Pulled By: mergennachin
11c1364 to
d900ad0CompareSummary: Did not add as core aten op. But used "func" and enabled exporting via: ``` to_edge_transform_and_lower( exported_program, partitioner=None, compile_config=EdgeCompileConfig( _core_aten_ops_exception_list=[ torch.ops.aten.bitwise_left_shift.Tensor, torch.ops.aten.bitwise_left_shift.Tensor_Scalar, torch.ops.aten.bitwise_right_shift.Tensor, torch.ops.aten.bitwise_right_shift.Tensor_Scalar, ] ), ) ``` In the future, we may promote to core aten op. Differential Revision: D87451202 Pulled By: mergennachin
d900ad0 to
1f8c9e5CompareSummary: Did not add as core aten op. But used "func" and enabled exporting via: ``` to_edge_transform_and_lower( exported_program, partitioner=None, compile_config=EdgeCompileConfig( _core_aten_ops_exception_list=[ torch.ops.aten.bitwise_left_shift.Tensor, torch.ops.aten.bitwise_left_shift.Tensor_Scalar, torch.ops.aten.bitwise_right_shift.Tensor, torch.ops.aten.bitwise_right_shift.Tensor_Scalar, ] ), ) ``` In the future, we may promote to core aten op. Differential Revision: D87451202 Pulled By: mergennachin
1f8c9e5 to
c1ad491CompareUh oh!
There was an error while loading. Please reload this page.
Fixespytorch#15673 (comment) Did not add as core aten op. But used "func" and enabled exporting via: ``` to_edge_transform_and_lower( exported_program, partitioner=None, compile_config=EdgeCompileConfig( _core_aten_ops_exception_list=[ torch.ops.aten.bitwise_left_shift.Tensor, torch.ops.aten.bitwise_left_shift.Tensor_Scalar, torch.ops.aten.bitwise_right_shift.Tensor, torch.ops.aten.bitwise_right_shift.Tensor_Scalar, ] ), ) ``` In the future, we may promote to core aten op.
Fixes#15673 (comment)
Did not add as core aten op. But used "func" and enabled exporting via:
In the future, we may promote to core aten op.