Skip to content

Commit f7862e7

Browse files
authored
[Relay][Frontend[Onnx] Add testing for output datatypes and fix related bugs. (apache#7364)
* Add testing for datatypes and fix related bugs. * Fix lint issue in onnx.
1 parent f7275f9 commit f7862e7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

python/tvm/relay/frontend/onnx.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ def _impl_v1(cls, inputs, attr, params):
14511451
axis = attr.get("axis", 0)
14521452
keepdims = attr.get("keepdims", True)
14531453
attr = {"axis": axis, "keepdims": keepdims}
1454-
return AttrCvt("argmax")(inputs, attr)
1454+
return _op.cast(AttrCvt("argmax")(inputs, attr), "int64")
14551455

14561456

14571457
class ArgMin(OnnxOpConverter):
@@ -1462,7 +1462,7 @@ def _impl_v1(cls, inputs, attr, params):
14621462
axis = attr.get("axis", 0)
14631463
keepdims = attr.get("keepdims", True)
14641464
attr = {"axis": axis, "keepdims": keepdims}
1465-
return AttrCvt("argmin")(inputs, attr)
1465+
return _op.cast(AttrCvt("argmin")(inputs, attr), "int64")
14661466

14671467

14681468
class Softmax(OnnxOpConverter):
@@ -2000,7 +2000,7 @@ def _impl_v1(cls, inputs, attr, params):
20002000
if largest == 0:
20012001
raise ValueError("TVM only supports finding TopK largest elements")
20022002

2003-
return _op.topk(inputs[0], inputs[1], axis=axis)
2003+
return _op.topk(inputs[0], inputs[1], axis=axis, dtype="int64")
20042004

20052005

20062006
class Range(OnnxOpConverter):

tests/python/frontend/onnx/test_forward.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def verify_with_ort_with_inputs(
163163
ort_val = scipy.special.softmax(ort_val)
164164
tvm_val = scipy.special.softmax(tvm_val)
165165
tvm.testing.assert_allclose(ort_val, tvm_val, rtol=rtol, atol=atol)
166+
assert ort_val.dtype == tvm_val.dtype
166167

167168

168169
def verify_with_ort(

0 commit comments

Comments
 (0)