masahi commented on pull request #9884:
URL: https://github.com/apache/tvm/pull/9884#issuecomment-1009259779
ok I took a look at this model. The input list in question is not the "user
input", but it happens in the middle of the model:
```
%81 : Tensor[] = prim::ListConstruct(%77, %78, %79)
%82 : (Tensor, Tensor[]) = prim::TupleConstruct(%80, %81)
return (%82)
```
So although it is correct to say that the `prim::TupleConstruct` converter
needs to support a list of tensors, flattening everything as in this PR is not
correct. That would be ok for this model since the constructed tuple is the
return value, but otherwise the conversion would be broken.
The following is "more correct", but it only handles one level of nesting.
We need to recursively construct a tuple for each tensor list nested within
another list. @zhaojinxi Please update the PR with a test case.
```
elif operator == "prim::TupleConstruct":
inputs_list = []
for i, _ in enumerate(inputs):
if isinstance(inputs[i], list):
inputs_list.append(_expr.Tuple(inputs[i]))
else:
assert isinstance(inputs[i], _expr.Expr)
inputs_list.append(inputs[i])
outputs[node_name] = _expr.Tuple(inputs_list)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]