• moto's avatar
    Split extension into custom impl and Python wrapper libraries (#1752) · 0f822179
    moto authored
    * Split `libtorchaudio` and `_torchaudio`
    
    This change extract the core implementation from `_torchaudio` to `libtorchaudio`,
    so that `libtorchaudio` is reusable in TorchScript-based app.
    
    `_torchaudio` is a wrapper around `libtorchaudio` and only provides PyBind11-based
    features. (currently file-like object support in I/O)
    
    * Removed `BUILD_LIBTORCHAUDIO` option
    
    When invoking `cmake`, `libtorchaudio` is always built, so this option is removed.
    
    The new assumptions around the library discoverability
    
    - In regular OSS workflow (`pip`/`conda`-based binary installation), both `libtorchaudio` and `_torchaudio` are present.
        In this case,`libtorchaudio` has to be loaded manually with `torch.ops.load_library` and/or `torch.classes.load_library` otherwise importing `_torchaudio` would not be able to resolve the symbols defined in `libtorchaudio`.
    - When `torchaudio` is deployed with PEX format (single zip file)
      - We expect that`libtorchaudio.so` exists as a file in some search path configured by client code.
      - `_torchaudio` is still importable and because we do not know where `libtorchaudio` will exist, we will let the dynamic loader resolve the dependency from `_torchaudio` to `libtorchaudio`, which should work as long as `libtorchaudio` is in a library search path (search path is not modifiable from already-running Python process).
    0f822179
extension.py 5.42 KB