Refactor the library loading mechanism (#2038)
Summary: (This is a part of refactor series, followed up by https://github.com/pytorch/audio/issues/2039 and https://github.com/pytorch/audio/issues/2040. The goal is to make it easy to add a new library artifact alongside with `libtorchudio`, as in https://github.com/pytorch/audio/pull/2048/commits/4ced990849e60f6d19e87ae22819b04d1726648e https://github.com/pytorch/audio/issues/2048 .) We plan to add prototype/beta third party library integrations, which could be unstable. (segfault, missing dynamic library dependencies etc...) If we add such integrations into the existing libtorchaudio, in the worst case, it will prevent users from just `import torchaudio`. Instead, we would like to separate the prototype/beta integrations into separate libraries, so that such issues would not impact all users but users who attempt to use these prototytpe/beta features. Say, a prototype feature `foo` is added in `torchaudio.prototype.foo`. The following initialization procedure will achieve the above mechanism. 1. Place the library file `libtorchaudio_foo` in `torchaudio/lib`. 2. In `torchaudio.prototype.foo.__init__.py`, load the `libtorchaudio_foo`. Note: The approach will be slightly different for fbcode, because of how buck deploys C++ libraries and standardized environment, but the code change here is still applicable. Pull Request resolved: https://github.com/pytorch/audio/pull/2038 Reviewed By: carolineechen, nateanl Differential Revision: D32682900 Pulled By: mthrok fbshipit-source-id: 0f402a92a366fba8c2894a0fe01f47f8cdd51376
Showing
Please register or sign in to comment