Last active
December 1, 2020 16:30
-
-
Save NegatioN/cc8143d351ba8776d26b40e159780cf7 to your computer and use it in GitHub Desktop.
How to input python-esque kwargs to a pytorch scripted c++ model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
torch::jit::IValue myIvalue; | |
torch::jit::IValue myIvalue2; | |
torch::jit::script::Module module; | |
std::unordered_map<std::string, torch::jit::IValue> umap = {{"x", myIvalue}, {"opt", myIvalue2}}; | |
auto result = module.get_method("forward")({}, umap); | |
// shows all potential arguments to model forward | |
std::cout << module.get_method("forward").function().getSchema().arguments() << std::endl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment