Skip to content

Commit

Permalink
add onnx elemwise greater/less (#3186)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhreshold authored and tqchen committed May 13, 2019
1 parent f72c763 commit 134a2f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,23 @@ def _impl_v1(cls, inputs, attr, params):
extras={'axis':axis})(inputs, {})
#return _op.take(inputs[0], inputs[1], axis)


class Greater(OnnxOpConverter):
""" Operator logical greater.
"""
@classmethod
def _impl_v7(cls, inputs, attr, params):
return _op.greater(inputs[0], inputs[1])


class Less(OnnxOpConverter):
""" Operator logical less than.
"""
@classmethod
def _impl_v7(cls, inputs, attr, params):
return _op.less(inputs[0], inputs[1])


class LRN(OnnxOpConverter):
""" Operator converter for Local Response Normalization.
"""
Expand Down Expand Up @@ -836,6 +853,8 @@ def _get_convert_map(opset):
'Selu': Selu.get_converter(opset),
'Elu': Elu.get_converter(opset),
'Exp': Renamer('exp'),
'Greater': Greater.get_converter(opset),
'Less': Less.get_converter(opset),
'Log': Renamer('log'),
'Tanh': Renamer('tanh'),
'Pow': Renamer('power'),
Expand Down
2 changes: 2 additions & 0 deletions tests/python/frontend/onnx/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,8 @@ def verify_binary_ops(op, x, y, out_np, broadcast=None):
verify_binary_ops("Div", x, y, x / y, broadcast=None)
verify_binary_ops("Div", x, z, x / z, broadcast=True)
verify_binary_ops("Sum", x, y, x + y, broadcast=None)
verify_binary_ops("Greater", x, y, x > y, broadcast=True)
verify_binary_ops("Less", x, y, x < y, broadcast=True)

def test_single_ops():
in_shape = (1, 2, 3, 3)
Expand Down

0 comments on commit 134a2f2

Please sign in to comment.