Using Dict[str, Tensor] type as a argument for a jit script_method

I have a model whose predict method takes an argument of type Dict[str, Tensor].
I have been able to successfully serialize and save the model as a ScriptModule.
Now I want to test the model from c++ front-end, but I am not able to figure out how to create a test-input using the c++ front-end having the required type of Dict[str, Tensor].

Another related question: How can I save an input of this type from python so that I will be able to later load it the form c++ frontend in order to test the ScriptModule with this input?

I put up an end-to-end example that should help. The dict construction in C++ can be found here. Please follow up if anything is still unclear.

For your other question, we don’t support that yet but it shouldn’t take too long to add, you can track it here:

1 Like