Open Registration for torch::deploy Builtins (#65953)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65953
Previously if people want to add a torch::deploy builtin, they need to change torch::deploy internal code (interpreter_impl.cpp) to register the python part as frozen modules and C++ part as builtin modules. This is not convenient and error prone. We want to add open registration support for torch::deploy builtins so that people only need to add one effective line of code in there *library code* to complete the registration.
Here is an example to registry numpy as torch::deploy builtins:
REGISTER_TORCH_DEPLOY_BUILTIN(numpy, numpy_frozen_modules, <list of name, PyInit function pairs>)
This diff supports open registration of frozen modules. It's the first step to achieve the plan above.
ghstack-source-id: 139888306
Test Plan: Run tests in test_deploy.cpp and test_builtin_registry.cpp
Reviewed By: suo
Differential Revision: D31321562
fbshipit-source-id: 6445bd8869f1bb7126b4c96cf06c31145f0e9445