Skip to content

[TorchToStableHLO] Support bitwise_or.Scalar and bitwise_xor.Scalar l…#4496

Open
BruceXinXin wants to merge 1 commit intollvm:mainfrom
BruceXinXin:bruce_add_or_and_xor_lowering
Open

[TorchToStableHLO] Support bitwise_or.Scalar and bitwise_xor.Scalar l…#4496
BruceXinXin wants to merge 1 commit intollvm:mainfrom
BruceXinXin:bruce_add_or_and_xor_lowering

Conversation

@BruceXinXin
Copy link

[TorchToStableHLO] Support bitwise_or.Scalar and bitwise_xor.Scalar lowerings

Summary

The Scalar variants of bitwise_or and bitwise_xor were missing from
both the Torch dialect and the StableHLO conversion. The Tensor variants
existed, and bitwise_and.Scalar was already supported, but or and xor
with scalar operands were not handled.

…owerings

Add Torch dialect op definitions for aten::bitwise_or.Scalar and
aten::bitwise_xor.Scalar (along with their inplace variants), and
lower them to StableHLO via chlo::BroadcastOrOp and
chlo::BroadcastXorOp respectively.

This reuses the existing ConvertAtenLogicalBinaryOp template which
already handles scalar-to-tensor promotion and broadcasting, matching
the pattern used by bitwise_and.Scalar.
@BruceXinXin
Copy link
Author

@li-plus @sjarus a review plus :)

@BruceXinXin BruceXinXin marked this pull request as ready for review March 10, 2026 20:04
@sjarus sjarus requested a review from li-plus March 11, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant