Allow torch.utils.cpp_extension.load to load shared libraries that aren't Python...
authorPeter Goldsborough <psag@fb.com>
Mon, 26 Nov 2018 17:37:04 +0000 (09:37 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 26 Nov 2018 17:39:21 +0000 (09:39 -0800)
commita13fd7ec282077046e6eaaaca6596efca9f00d2f
tree1dff1e160caeb9862a219c40d0a1ad4149f97887
parenta60368982b1c4110861a8d678aa7f61b119a43c4
Allow torch.utils.cpp_extension.load to load shared libraries that aren't Python modules (#13941)

Summary:
For custom TorchScript operators, `torch.ops.load_library` must be used and passed the path to the shared library containing the custom ops. Our C++ extensions stuff generally is meant to build a Python module and import it. This PR changes `torch.utils.cpp_extension.load` to have an option to just return the shared library path instead of importing it as a Python module, so you can then pass it to `torch.ops.load_library`. This means folks can re-use `torch.utils.cpp_extension.load` and `torch.utils.cpp_extension.load_inline` to even write their custom ops inline. I think t-vi  and fmassa will appreciate this.

soumith
Pull Request resolved: https://github.com/pytorch/pytorch/pull/13941

Differential Revision: D13110592

Pulled By: goldsborough

fbshipit-source-id: 37756307dbf80a81d2ed550e67c8743dca01dc20
test/test_cpp_extensions.py
torch/utils/cpp_extension.py