Skip to content

Conversation

philass
Copy link
Member

@philass philass commented Sep 8, 2022

Signed-off-by: Philip Lassen philiplassen+git@gmail.com

Description

This PR implements the BitwiseNot operator. I've implemented the Binary bitwise operators in #4496.

Motivation and Context

With this PR and #4496 we have implementations for the same set of bitwise operators numpy has support for.

  • np.bitwise_and
  • np.bitwise_or
  • np.bitwise_xor
  • np.bitwise_not

The are also the same set of Ops which already have a ONNX logical equivalent. And, Or, Xor, and Not. In ONNX these take booleans and return booleans. This also touches on @AlexandreEichenberger's comments in #4343

@philass philass marked this pull request as ready for review September 8, 2022 15:15
@philass philass requested review from a team as code owners September 8, 2022 15:15
@gramalingam gramalingam added the topic: operator Issues related to ONNX operators label Sep 14, 2022
@gramalingam
Copy link
Contributor

LGTM, thanks! The only question is whether some of the ops should be defined as functions in terms of others.

@philass philass force-pushed the plassen/bitwise-not branch from ad84f41 to ffba00b Compare September 28, 2022 17:47
@philass
Copy link
Member Author

philass commented Sep 28, 2022

Thanks for the review!

LGTM, thanks! The only question is whether some of the ops should be defined as functions in terms of others.

I think bitwise ops are sufficiently primitive where it may be overkill to make some of these functions. From my understanding most chips and hardware accelerators have first class support for these bitwise operations.

However if you feel that this is best done with functions, I can try and figure out how to do that.

@gramalingam
Copy link
Contributor

Thanks for the review!

LGTM, thanks! The only question is whether some of the ops should be defined as functions in terms of others.

I think bitwise ops are sufficiently primitive where it may be overkill to make some of these functions. From my understanding most chips and hardware accelerators have first class support for these bitwise operations.

However if you feel that this is best done with functions, I can try and figure out how to do that.

Not necessary. I think this is fine. I agree that in practice, it won't make a big difference.

Signed-off-by: Philip Lassen <philiplassen+git@gmail.com>
@philass philass force-pushed the plassen/bitwise-not branch from ffba00b to 583b359 Compare September 28, 2022 20:57
Copy link
Contributor

@p-wysocki p-wysocki left a comment

Choose a reason for hiding this comment

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

Would testing 0d tensor inputs (scalars, essentially) bring any benefits? LGTM.

@philass
Copy link
Member Author

philass commented Oct 3, 2022

@p-wysocki thanks for the review!

I checked other unary and binary ops. And it seems that most times 0d tensors aren't checked.

If you feel it would add more coverage, then I am happy to add tests.

@gramalingam gramalingam merged commit bc0377e into onnx:main Oct 3, 2022
broune pushed a commit to broune/onnx that referenced this pull request May 6, 2023
Signed-off-by: Philip Lassen <philiplassen+git@gmail.com>

Signed-off-by: Philip Lassen <philiplassen+git@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: operator Issues related to ONNX operators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants