Skip to content

Commit b9640ec

Browse files
committed
unary
1 parent 21ec1de commit b9640ec

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

_unittests/ut_reference/test_torch_evaluator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,16 @@ def test_op_binary_cmp(self):
8888
model = oh.make_model(
8989
oh.make_graph(
9090
[
91-
oh.make_node("Greater", ["X", "Y"], ["a"]),
91+
oh.make_node("Neg", ["X"], ["nx"]),
92+
oh.make_node("Reciprocal", ["nx"], ["rnx"]),
93+
oh.make_node("Greater", ["X", "rnx"], ["a"]),
9294
oh.make_node("GreaterOrEqual", ["X", "Y"], ["b"]),
9395
oh.make_node("Less", ["X", "Y"], ["c"]),
9496
oh.make_node("LessOrEqual", ["X", "Y"], ["d"]),
9597
oh.make_node("And", ["a", "b"], ["ab"]),
9698
oh.make_node("Or", ["c", "d"], ["cd"]),
97-
oh.make_node("And", ["ab", "cd"], ["Z"]),
99+
oh.make_node("Not", ["cd"], ["ncd"]),
100+
oh.make_node("And", ["ab", "ncd"], ["Z"]),
98101
],
99102
"dummy",
100103
[

onnx_diagnostic/reference/torch_ops/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
from .other_ops import Cast_6, Concat_1, Transpose_1
1717
from .nn_ops import Softmax_13, Tanh_6
1818
from .shape_ops import Reshape_14, Shape_15, Squeeze_13, Unsqueeze_13
19+
from .unary_ops import Neg_1, Not_1, Reciprocal_1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from . import OpRun, OpRunValue
2+
3+
4+
class Neg_1(OpRun):
5+
"""Neg"""
6+
7+
def run(self, x: OpRunValue) -> OpRunValue:
8+
return OpRunValue(-x.tensor)
9+
10+
11+
class Not_1(OpRun):
12+
"""Not"""
13+
14+
def run(self, x: OpRunValue) -> OpRunValue:
15+
return OpRunValue(~x.tensor)
16+
17+
18+
class Reciprocal_1(OpRun):
19+
"""REciprocal"""
20+
21+
def run(self, x: OpRunValue) -> OpRunValue:
22+
return OpRunValue(1 / x.tensor)

0 commit comments

Comments
 (0)