Skip to content

Conversation

@mergennachin
Copy link
Contributor

@mergennachin mergennachin commented Nov 19, 2025

Fixes #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.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 19, 2025
@mergennachin
Copy link
Contributor Author

#15673 (comment)

@meta-codesync
Copy link

meta-codesync bot commented Nov 19, 2025

@mergennachin has imported this pull request. If you are a Meta employee, you can view this in D87451202.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_shift and bitwise_right_shift operators 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.

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 19, 2025

🔗 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 Failures

As of commit c1ad491 with merge base 62dccf1 (image):

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.

facebook-github-bot pushed a commit that referenced this pull request Dec 3, 2025
Summary: Pull Request resolved: #15893

Differential Revision: D87451202

Pulled By: mergennachin
@meta-codesync
Copy link

meta-codesync bot commented Dec 3, 2025

@mergennachin has exported this pull request. If you are a Meta employee, you can view the originating Diff in D87451202.

mergennachin added a commit that referenced this pull request Dec 3, 2025
Summary: Pull Request resolved: #15893

Differential Revision: D87451202

Pulled By: mergennachin
@mergennachin mergennachin changed the title WIP: Add bitwise left/right Add bitwise left/right Dec 3, 2025
@mergennachin mergennachin marked this pull request as ready for review December 3, 2025 16:42
Copilot AI review requested due to automatic review settings December 3, 2025 16:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

facebook-github-bot pushed a commit that referenced this pull request Dec 3, 2025
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
facebook-github-bot pushed a commit that referenced this pull request Dec 3, 2025
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
Copilot AI review requested due to automatic review settings December 3, 2025 17:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mergennachin mergennachin requested a review from lucylq December 3, 2025 18:24
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
@manuelcandales manuelcandales added the release notes: ops & kernels Changes to the opset and any new / changed kernel implementations label Dec 8, 2025
@manuelcandales manuelcandales merged commit 3a76a8b into main Dec 8, 2025
160 of 165 checks passed
@manuelcandales manuelcandales deleted the bitwise_shift branch December 8, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported release notes: ops & kernels Changes to the opset and any new / changed kernel implementations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot run generated .pte file due to missing aten::bitwise_right_shift operator

3 participants