From ce1ec3a51ed875a76ed8301983c1290fcf014af4 Mon Sep 17 00:00:00 2001 From: Trevor Morris Date: Thu, 10 Dec 2020 22:20:20 +0000 Subject: [PATCH] Handle case where ListConstruct makes a python list which is output of whole model --- python/tvm/relay/frontend/pytorch.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/tvm/relay/frontend/pytorch.py b/python/tvm/relay/frontend/pytorch.py index ca188c78322a..091884379e00 100644 --- a/python/tvm/relay/frontend/pytorch.py +++ b/python/tvm/relay/frontend/pytorch.py @@ -3038,7 +3038,10 @@ def from_pytorch(script_module, input_infos, custom_convert_map=None, default_dt qnn_torch.add_quant_params(tvm_params, weight_quant_params) converter.update_convert_map(qnn_torch.convert_map) - ret = converter.convert_operators(_get_operator_nodes(graph.nodes()), outputs, ret_name) + ret = converter.convert_operators(_get_operator_nodes(graph.nodes()), outputs, ret_name)[0] + if isinstance(ret, list): + # ListConstruct kept original python list. Convert to tuple. + ret = _expr.Tuple(ret) - mod["main"] = tvm.relay.Function(_analysis.free_vars(ret[0]), ret[0]) + mod["main"] = tvm.relay.Function(_analysis.free_vars(ret), ret) return transform.RemoveUnusedFunctions()(mod), tvm_params