Repository navigation
Add bitwise left/right - #15893
Add bitwise left/right#15893
Conversation
|
@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.
🔗 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
8c43463
Compare
|
@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
11c1364
Compare
There 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
d900ad0
Compare
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
d900ad0 to
1f8c9e5
Compare
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
1f8c9e5 to
c1ad491
Compare
Fixes pytorch#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 #20270 ### Summary Add portable scalar and tensor bucketize operator, based on the PyTorch implementation. Key differences from the PyTorch implementation: - Implemented only bucketize, no searchsorted - Boundaries tensor size is not checked against output type, as `SizesType` is an `int32_t` and must be 1D - In the original implementation the input scalar is wrapped into a tensor, here two sets of functions are used instead - Supports both NHWC and NCHW as it is a pointwise kernel and there is no sorter argument. This avoids creating contiguous tensors - Stayed as close to the PyTorch version as possible, should a searchsorted implementation be added in the future Release notes: ops & kernels ### Test plan C++ tests are extensive and include failure and edge cases tests. Python tests compare the output of an exported module to the PyTorch implementation only for normal and edge cases, similar to #15893. cc @larryliu0820 @manuelcandales --------- Signed-off-by: Gallinator <lcgallinator4@gmail.com>
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.