Skip to content

Commit

Permalink
[Relay]Frontend][Onnx] Remove pop that interferes with nested loops. (a…
Browse files Browse the repository at this point in the history
…pache#7781)

* Remove popping that interferes with nested loops.

* Only check user inputs in the outer-most graph scope.

* Fix style.

Co-authored-by: Ubuntu <jwfromm@jwfromm-cpu-dev.itxhlkosmouevgkdrmwxfbs5qh.xx.internal.cloudapp.net>
  • Loading branch information
2 people authored and Trevor Morris committed May 6, 2021
1 parent be75284 commit 8f45c44
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2981,6 +2981,7 @@ def __init__(self, shape, dtype, freeze_params=False):
self._num_input = 0
self._num_param = 0
self._shape = shape if shape else {}
self._input_names = []
self._dtype = dtype
self.opset = None
self._freeze_params = freeze_params
Expand Down Expand Up @@ -3062,8 +3063,9 @@ def from_onnx(self, graph, opset, get_output_expr=False):
continue
else:
self._num_input += 1
self._input_names.append(i_name)
if i_name in self._shape:
i_shape = self._shape.pop(i_name)
i_shape = self._shape[i_name]
else:
if "?" in str(i_shape):
warning_msg = (
Expand All @@ -3078,11 +3080,13 @@ def from_onnx(self, graph, opset, get_output_expr=False):
dtype = d_type
self._nodes[i_name] = new_var(i_name, shape=i_shape, dtype=dtype)
self._inputs[i_name] = self._nodes[i_name]
assert (
len(self._shape) == 0
), "User specified the shape for inputs that weren't found in the graph: " + str(
self._shape
)
# Only check user inputs in the outer-most graph scope.
if self._old_manager is None:
assert all(
[name in self._input_names for name in self._shape.keys()]
), "User specified the shape for inputs that weren't found in the graph: " + str(
self._shape
)
# get list of unsupported ops
convert_map = _get_convert_map(opset)
unsupported_ops = set()
Expand Down

0 comments on commit 8f45c44

Please sign in to comment.