Skip to content

Commit

Permalink
fix pytorch frontend bug (apache#9884)
Browse files Browse the repository at this point in the history
* fix pytorch frontend bug

* update

* update

Co-authored-by: zhaojinxi <[email protected]>
  • Loading branch information
zhaojinxi and zhaojinxi authored Jan 13, 2022
1 parent 48006f2 commit de6a022
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion python/tvm/relay/frontend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3292,7 +3292,18 @@ def convert_operators(self, operators, outputs, ret_names):
# In this case, we keep the Python list
outputs[node_name] = inputs
elif operator == "prim::TupleConstruct":
outputs[node_name] = _expr.Tuple(inputs)

def _handel_nested_input(inputs):
inputs_list = []
for i, _ in enumerate(inputs):
if isinstance(inputs[i], list):
inputs_list.append(_handel_nested_input(inputs[i]))
else:
assert isinstance(inputs[i], _expr.Expr)
inputs_list.append(inputs[i])
return _expr.Tuple(inputs_list)

outputs[node_name] = _handel_nested_input(inputs)
elif operator in ["prim::ListUnpack", "prim::TupleUnpack"]:
assert len(inputs) == 1
if isinstance(inputs[0], (list, _expr.TupleWrapper)):
Expand Down

0 comments on commit de6a022

Please sign in to comment.