Skip to content

Conversation

justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Sep 29, 2025

This PR

  1. Consolidates logic for bitwise_* functions so that the logical_* functions are no longer handling bool overloads of the bitwise ops.
  2. Adds support for integer inputs in the logical_* implementations.

Replacement of #2579.

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Copy link
Contributor

@Copilot 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 integer inputs to PyTorch's logical operators (logical_and, logical_or, logical_not, logical_xor) in the torchlib implementation. The changes modify these operators to accept generic tensor types and handle both boolean and integer inputs by casting integers to boolean when needed.

  • Separates bitwise operations from logical operations for better type safety
  • Updates logical operators to accept TTensor instead of just BOOL types
  • Adds test coverage for the newly supported logical operators

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/function_libs/torch_lib/ops_test_data.py Adds test entries for logical_and, logical_not, logical_or, and logical_xor operators
onnxscript/function_libs/torch_lib/ops/core.py Refactors bitwise and logical operators to handle different data types properly, adding integer support to logical ops

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby justinchuby changed the title [torchlib] Support integers in logical_and/or ops [torchlib] Support integers in logical_and/or ops and update other logical ops Sep 29, 2025
@justinchuby justinchuby modified the milestones: 0.5.2, 0.5.3 Sep 29, 2025
@justinchuby justinchuby requested a review from Copilot September 29, 2025 18:32
Copy link
Contributor

@Copilot 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 2 out of 2 changed files in this pull request and generated 2 comments.

Copy link

codecov bot commented Sep 29, 2025

Codecov Report

❌ Patch coverage is 85.45455% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.07%. Comparing base (dddf0c2) to head (ec8bda3).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
onnxscript/function_libs/torch_lib/ops/core.py 85.45% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2582      +/-   ##
==========================================
+ Coverage   70.04%   70.07%   +0.02%     
==========================================
  Files         223      223              
  Lines       26215    26249      +34     
  Branches     2583     2597      +14     
==========================================
+ Hits        18363    18393      +30     
  Misses       6946     6946              
- Partials      906      910       +4     

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

justinchuby and others added 2 commits September 29, 2025 11:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@titaiwangms titaiwangms left a comment

Choose a reason for hiding this comment

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

Is this PR fixing some bugs or just moving code around to improve code quality? I see it combines some code to avoid function-signature dispatching? It would be better we put motivation and result in the description, since the linked PR (original) did not specify either.

@justinchuby
Copy link
Collaborator Author

@titaiwangms Updated, thanks

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby justinchuby enabled auto-merge (squash) September 29, 2025 22:28
@justinchuby justinchuby merged commit df8f706 into main Sep 29, 2025
32 checks passed
@justinchuby justinchuby deleted the justinchu/and-int branch September 29, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: torchlib Related to the torch/aten function lib in development

Projects

Development

Successfully merging this pull request may close these issues.

2 participants