Skip to content

Adding bitwise ONNX ops #3120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

AshAnand34
Copy link
Contributor

@AshAnand34 AshAnand34 commented Apr 30, 2025

Pull Request Template

Checklist

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

#1714

Changes

Developed the bitwise operators in burn while following the steps from the contributor book:

  • BitShift
  • BitwiseAnd
  • BitwiseNot
  • BitwiseOr
  • BitwiseXor

Testing

Developed unit tests for each of the bitwise operators.

@antimora antimora added the onnx label May 5, 2025
@AshAnand34 AshAnand34 marked this pull request as ready for review May 7, 2025 06:20
Copy link
Member

@laggui laggui left a comment

Choose a reason for hiding this comment

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

Looks like the scalar case is not correctly handled (see CI errors).

Also, the ONNX tests refactor in #3144 (merged) have introduced a minor conflict with the removal of the test_onnx.rs file.

@antimora
Copy link
Collaborator

All major reorg refactoring is done. Let me know if you need to help with merging. Please see updated book section:

cargo xtask books contributor open

You can also pick into a recent PR merged with tests/configuration locations: #3177

Copy link
Contributor

This PR has been marked as stale because it has not been updated for over a month

@github-actions github-actions bot added the stale The issue or pr has been open for too long label Jun 10, 2025
@laggui laggui closed this Jun 19, 2025
@antimora
Copy link
Collaborator

I can finish it when I am back

@laggui laggui reopened this Jun 20, 2025
@laggui laggui marked this pull request as draft June 20, 2025 11:39
@github-actions github-actions bot removed the stale The issue or pr has been open for too long label Jun 20, 2025
antimora added 7 commits July 11, 2025 15:10
Updated bitwise and bitshift node implementations to accept both tensor and scalar inputs via the Type enum, enabling proper handling of scalar operations. Adjusted code generation logic and import registration for scalar cases, and updated ONNX conversion functions to use Type instead of TensorType. Also fixed a test expectation in bitwise_xor and enabled bitwise tests in test_mod.rs.
Rewrote bitshift.py to generate ONNX models directly using the onnx API, supporting both tensor and scalar shift inputs. Updated all BitShift ONNX test models to match the new generation method and re-enabled the bitshift test module in test_mod.rs.
Replaced direct bitwise operators with corresponding Tensor methods (e.g., bitwise_and, bitwise_or, bitwise_not, bitwise_xor, bitwise_left_shift, bitwise_right_shift) in test modules for bitwise node implementations. Also updated input type registration in BitwiseAndNode tests for consistency.
@antimora antimora changed the title Adding bitwise ops Adding bitwise ONNX ops Jul 11, 2025
@antimora antimora marked this pull request as ready for review July 11, 2025 22:52
@antimora
Copy link
Collaborator

@laggui I have resolved all merge issues (and fixed some additional). Ready for review.

@antimora antimora requested a review from laggui July 11, 2025 23:02
Marked BitShift, BitwiseAnd, BitwiseNot, BitwiseOr, BitwiseXor, and IsInf as supported in the ONNX ops table for both import and export. This reflects recent changes in operator support.
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.19%. Comparing base (1d0fed3) to head (6247a7d).

❌ Your project check has failed because the head coverage (35.19%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3120   +/-   ##
=======================================
  Coverage   35.19%   35.19%           
=======================================
  Files         342      342           
  Lines       53164    53164           
=======================================
  Hits        18709    18709           
  Misses      34455    34455           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@laggui
Copy link
Member

laggui commented Jul 14, 2025

Thanks! Will have a look soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants