Partially support tensor lists in loop/concat/stack (#30126)
Summary:
This is a follow-up PR after https://github.com/pytorch/pytorch/pull/29136 ~~and https://github.com/pytorch/pytorch/pull/29171~~
ONNX::Loop does not support Sequence type as loop-carried dependencies. Only tensors are supported.
This PR adds a pass that converts Sequence loop-carried dependencies to scan_outputs.
In opset 11, only the below pattern is supported.
```
PTIR graph:
...
%res.1 : Tensor[] = prim::ListConstruct()
%res : Tensor[] = prim::Loop(%11, %22, %res.1)
block0(%i.1 : Tensor, %res.6 : Tensor[]):
...
%res.3 : Tensor[] = aten::append(%res.6, %17)
-> (%22, %res.3)
return (%res.3)
ONNX graph:
...
%res : Tensor = onnx::Loop(%11, %22)
block0(%i.1 : Tensor):
...
-> (%22, %17)
%res_seq : Tensor[] = onnx::SplitToSequence[keepdims=0](%res)
return (%res_seq)
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30126
Reviewed By: hl475
Differential Revision: D18946880
Pulled By: houseroad
fbshipit-source-id: 67ee65700513e8a942344a3d647e2e73c19ee3d2