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

[Relay][Frontend[Onnx] Add testing for output datatypes and fix related bugs. #7364

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ def _impl_v1(cls, inputs, attr, params):
axis = attr.get("axis", 0)
keepdims = attr.get("keepdims", True)
attr = {"axis": axis, "keepdims": keepdims}
return AttrCvt("argmax")(inputs, attr)
return _op.cast(AttrCvt("argmax")(inputs, attr), 'int64')


class ArgMin(OnnxOpConverter):
Expand All @@ -1462,7 +1462,7 @@ def _impl_v1(cls, inputs, attr, params):
axis = attr.get("axis", 0)
keepdims = attr.get("keepdims", True)
attr = {"axis": axis, "keepdims": keepdims}
return AttrCvt("argmin")(inputs, attr)
return _op.cast(AttrCvt("argmin")(inputs, attr), 'int64')


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

return _op.topk(inputs[0], inputs[1], axis=axis)
return _op.topk(inputs[0], inputs[1], axis=axis, dtype='int64')


class Range(OnnxOpConverter):
Expand Down
1 change: 1 addition & 0 deletions tests/python/frontend/onnx/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def verify_with_ort_with_inputs(
ort_val = scipy.special.softmax(ort_val)
tvm_val = scipy.special.softmax(tvm_val)
tvm.testing.assert_allclose(ort_val, tvm_val, rtol=rtol, atol=atol)
assert ort_val.dtype == tvm_val.dtype


def verify_with_ort(
Expand Down