Skip to content

Conversation

@eaten-cake
Copy link
Contributor

Addresses issue #17991.

This PR corrects the classification of the bitwise_not operation from binary to unary by modifying the BitwiseNot implementation class.
BitwiseNot previously inherited from this specific class, which was a subclass of BinaryBase.

class BitwiseBase(BinaryBase):
"""Converts an onnx BitwiseBase node into an equivalent Relax expression."""
@classmethod
def base_impl(cls, bb, inputs, attr, params):
"""Base implementation for bitwise operations."""
valid_types = ["int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64"]
for num, inp in enumerate(inputs):
if inp.struct_info.dtype not in valid_types:
raise ValueError(
f"Bitwise operations expect all inputs to have integer types, "
f"got {inp.struct_info.dtype} for input {num}"
)
return super().base_impl(bb, inputs, attr, params)

However, BinaryBase needs two operands in this case.
return cls.relax_op(inputs[0], inputs[1]) # pylint: disable=not-callable

@Hzfengsy
Copy link
Member

Thanks for the fix, please add a regression test case

@eaten-cake
Copy link
Contributor Author

Thanks for the fix, please add a regression test case

The regression tests have been added. Since the previous CI did not support opset18, I have removed the skip statements. The current tests can now cover the issue.

@Hzfengsy Hzfengsy merged commit ada7c7c into apache:main May 22, 2025
10 checks passed
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.

2 participants