Hi, I’m using a TorchScript Model on Pytorch C++ Frontend.
The model in Python return an output
dict as Dict[str, List[torch.Tensor]]
.
When I use it in C++, it return a c10::Dict<c10::IValue, c10::IValue>
. But what is the equivalents of this Python code:
value_a = output['key_a']
value_b = output['key_b']
in C++ to get value from c10::Dict
I have tried this but it does not work.
torch::IValue key_a("key_a");
torch::IValue key_b("key_b");
c10::IValue value_a = output[key_a];
c10::IValue value_b = output[key_b];
std::cout << value_a << std::endl;
std::cout << value_b << std::endl;
Output:
error: type 'c10::Dict<c10::IValue, c10::IValue>' does not provide a subscript operator
Anyone can give me a little help here. Thanks