I have a pytorch script which accepts Optional[Tuple[int, int]] as the input. The script is exported to “script.pb”.
Then in C++ api, the script.pb is loaded. But how can I create C++ obj of type Optional[Tuple[int, int]]? Is there any documentation?
Looks like there was a bug exposed by this use case…, the following will apply once this fix is merged.
Our C++ value type (IValue
) doesn’t have any concept of optional/not, it is either some concrete value (e.g. Tuple[int, int]
) or None
. Only the JIT’s type system knows what things can be optional. You can see a small example of how to construct one here.
The C++ API tests may also be helpful.
@driazati let’s make an issue tracking improved C++ API documentation, especially of IValues, etc… I’m seeing a lot of questions on it, and what we have now is not great.
1 Like
Just curious, in which case you need to create C++ obj of optional type? I think if you have Optional[Tuple[int, int]], you can always pass concrete objs into.