Skip to content

[Relax][ONNX] Fix default direction attribute decoding in BitShift - #20963

Open
Chaitanya140904 wants to merge 1 commit into
apache:mainfrom
Chaitanya140904:fix-onnx-bitshift-default-direction
Open

Chaitanya140904 wants to merge 1 commit into
apache:mainfrom
Chaitanya140904:fix-onnx-bitshift-default-direction

Conversation

@Chaitanya140904

Copy link
Copy Markdown

This PR fixes an AttributeError when decoding the direction attribute in the BitShift Relax ONNX operator converter.

Summary

Previously, BitShift._impl_v11 attempted to decode the direction attribute via attr.get("direction", "LEFT").decode("ascii"). When direction was omitted or defaulted to the string "LEFT", calling .decode("ascii") on a str raised AttributeError: 'str' object has no attribute 'decode'.

This change checks isinstance(direction, bytes) before calling .decode("ascii"), ensuring safe decoding whether the attribute is provided as bytes or str. It also adds unit tests covering BitShift with LEFT, RIGHT, multiple integer bit widths, and the default fallback when direction is omitted.

Closes #20950

This branch has not been deployed

No deployments
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.

[Bug][Relax][ONNX] BitShift raises AttributeError: 'str' object has no attribute 'decode' when direction attribute is omitted

1 participant