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] Improve dtype detection in loop to fix onnx tests. #7934

Merged
merged 1 commit into from
May 3, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@


class onnx_input:
""" Dual purpose list or dictionary access object."""
"""Dual purpose list or dictionary access object."""

def __init__(self):
self.input_keys = []
Expand Down Expand Up @@ -126,7 +126,10 @@ def get_info(info_proto):
shape.append(value)

name = info_proto.name
dtype = get_type(info_proto.type.tensor_type.elem_type)
if info_proto.type.tensor_type.elem_type:
dtype = get_type(info_proto.type.tensor_type.elem_type)
else:
dtype = None
return name, shape, dtype, shape_name


Expand Down Expand Up @@ -2405,6 +2408,8 @@ def get_var(name, val, scan=False):
scan_output_init = []
for i in range(num_scan_outputs):
name, shape, dtype, _ = get_info(body.output[i + 1 + num_deps])
if dtype is None:
dtype = infer_type(loop_deps[i]).checked_type.dtype
if dtype == "float":
dtype = "float32"
scan_output_vars.append(
Expand Down
6 changes: 2 additions & 4 deletions tests/python/frontend/onnx/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_input_data_shape_dict(graph_def, input_data):
def get_tvm_output_with_vm(
graph_def, input_data, target, device, opset=None, freeze_params=False, convert_to_static=False
):
""" Generic function to execute and get tvm output with vm executor"""
"""Generic function to execute and get tvm output with vm executor"""
if not isinstance(input_data, list):
input_data = [input_data]
_, shape_dict = get_input_data_shape_dict(graph_def, input_data)
Expand All @@ -67,7 +67,7 @@ def get_tvm_output_with_vm(
def get_tvm_output(
graph_def, input_data, target, device, output_shape=None, output_dtype="float32", opset=None
):
""" Generic function to execute and get tvm output"""
"""Generic function to execute and get tvm output"""
# TODO: Resolve the issues and remove the following lines
target = "llvm"
device = tvm.cpu(0)
Expand Down Expand Up @@ -4222,8 +4222,6 @@ def verify_cumsum(indata, axis, exclusive=0, reverse=0, type="float32"):
"test_qlinearconv/",
"test_qlinearmatmul_2D/",
"test_qlinearmatmul_3D/",
"test_range_float_type_positive_delta_expanded/",
"test_range_int32_type_negative_delta_expanded/",
"test_resize_tf_crop_and_resize/",
## For these three tests, ONNX 1.6.0 has incorrect graphs, they pass with ONNX 1.7.0
"test_resize_upsample_sizes_nearest_ceil_half_pixel/",
Expand Down