Skip to content
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

[ONNX] Bitshift Operator #7800

Merged
merged 1 commit into from Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions python/tvm/relay/frontend/onnx.py
Expand Up @@ -2782,6 +2782,24 @@ def _impl_v1(cls, inputs, attr, params):
return cls._op_dispatch(operator, inputs, attr, params)


class BitShift(OnnxOpConverter):
"""Operator converter for NonZero"""

@classmethod
def _impl_v11(cls, inputs, attr, params):
if len(inputs) != 2:
raise ValueError("Bitshift expects 2 inputs")

direction = attr.get("direction", "LEFT").decode("ascii")
if direction == "LEFT":
out = _op.left_shift(*inputs)
elif direction == "RIGHT":
out = _op.right_shift(*inputs)
else:
raise ValueError("Unsupported Shift Direction: " + direction)
return out


# compatible operators that do NOT require any conversion.
_identity_list = []

Expand All @@ -2796,6 +2814,7 @@ def _get_convert_map(opset):
# defs/experimental
"Identity": Renamer("copy"),
"Affine": Affine.get_converter(opset),
"BitShift": BitShift.get_converter(opset),
"ThresholdedRelu": ThresholdedRelu.get_converter(opset),
"ScaledTanh": ScaledTanh.get_converter(opset),
"ParametricSoftplus": ParametricSoftPlus.get_converter(opset),
Expand Down
8 changes: 0 additions & 8 deletions tests/python/frontend/onnx/test_forward.py
Expand Up @@ -4137,14 +4137,6 @@ def verify_cumsum(indata, axis, exclusive=0, reverse=0, type="float32"):

unsupported_onnx_tests = [
"test_basic_convinteger/",
"test_bitshift_left_uint16/",
"test_bitshift_left_uint32/",
"test_bitshift_left_uint64/",
"test_bitshift_left_uint8/",
"test_bitshift_right_uint16/",
"test_bitshift_right_uint32/",
"test_bitshift_right_uint64/",
"test_bitshift_right_uint8/",
"test_cast_DOUBLE_to_FLOAT16/",
"test_cast_FLOAT16_to_DOUBLE/",
"test_cast_FLOAT16_to_FLOAT/",
Expand Down