auto output = moudle.forward({image_tensor});
std::cout << output;
代码段运行正常,且能正常显示多个返回值。
使用.toTensorList() .toTensorVector() 等方法,一直在报 c10 或 c10::IValue 相关的错误
最后使用.toTuple() 方法能够提取到多个返回值。
auto output = moudle.forward({image_tensor}).toTuple();
torch::Tensor output1 = output->elements()[0].toTensor();
// 一定是指针运算符
torch::Tensor output2 = output->elements()[1].toTensor();