What is the best practice for adding multiple inputs and outputs for torch::jit::script::Module
?
I use below method:
// model
torch::jit::script::Module net_;
// input
std::vector<torch::jit::IValue> torch_inputs;
torch::Tensor a,b,c;
torch_inputs.push_back(a);
torch_inputs.push_back(b);
torch_inputs.push_back(c);
//
std::vector<at::Tensor> torch_outputs =
net_.forward(torch_inputs).toTensorVector();
// output
torch::Tensor o1 = torch_outputs[0];
torch::Tensor o2 = torch_outputs[1];
torch::Tensor o3 = torch_outputs[2];
My question is whether it is the best practice to do this, and how to be compatible if the input situation is not like this?