Convert c10::IValue to tensor or tuple failed

I’m runing a pytorch script_model in c++ , the model output is a List[Tensor] , when I prepare to parse it to c++ data structure, either run output.toTuple() or output.toTensor() is failed, and get similar error info like this “what(): isTuple() ASSERT FAILED at /data/home/…/libtorch/include/ATen/core/ivalue.h:246”. However, I can print the output directly, the format is [2
[ Variable[CPUType]{} ], 1
[ Variable[CPUType]{} ], 0
[ Variable[CPUType]{} ], 0
[ Variable[CPUType]{} ], 3
[ Variable[CPUType]{} ]]. How can convert the output to tensor or other c++ data structor?

Have you tried output.toTensorList() and then get the Tensors by indexing the returned list?

yes, this is helpful