-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move essential backend implementations to _backend (#3549)
Summary: Move the actual I/O implementation to `_backend` submodule so that the existing `backend` submodule contains only what's related to legacy backend utilities. Pull Request resolved: #3549 Reviewed By: huangruizhe Differential Revision: D48253550 Pulled By: mthrok fbshipit-source-id: c23f1664458c723f63e134c7974b3f7cf17a1e98
- Loading branch information
1 parent
c0f25f2
commit 2e0dfaf
Showing
14 changed files
with
76 additions
and
16 deletions.
There are no files selected for viewing
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
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
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
File renamed without changes.
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
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
File renamed without changes.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,42 @@ | ||
# NOTE: | ||
# The entire `torchaudio.backend` module is deprecated. | ||
# New things should be added to `torchaudio._backend`. | ||
# Only things related to backward compatibility should be placed here. | ||
|
||
from .utils import _init_backend, get_audio_backend, list_audio_backends, set_audio_backend | ||
|
||
|
||
__all__ = ["_init_backend", "get_audio_backend", "list_audio_backends", "set_audio_backend"] | ||
|
||
|
||
def __getattr__(name: str): | ||
if name == "common": | ||
from . import _common | ||
|
||
return _common | ||
|
||
if name in ["no_backend", "sox_io_backend", "soundfile_backend"]: | ||
import warnings | ||
|
||
warnings.warn( | ||
"Torchaudio's I/O functions now support par-call bakcend dispatch. " | ||
"Importing backend implementation directly is no longer guaranteed to work. " | ||
"Please use `backend` keyword with load/save/info function, instead of " | ||
"calling the udnerlying implementation directly.", | ||
stacklevel=2, | ||
) | ||
|
||
if name == "sox_io_backend": | ||
from . import _sox_io_backend | ||
|
||
return _sox_io_backend | ||
if name == "soundfile_backend": | ||
from torchaudio._backend import soundfile_backend | ||
|
||
return soundfile_backend | ||
|
||
if name == "no_backend": | ||
from . import _no_backend | ||
|
||
return _no_backend | ||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def __getattr__(name: str): | ||
import warnings | ||
|
||
if name == "AudioMetaData": | ||
warnings.warn( | ||
"`torchaudio.backend.common.AudioMetaData` has been moved to " | ||
"`torchaudio.AudioMetaData`. Please update the import path.", | ||
stacklevel=2, | ||
) | ||
from torchaudio._backend.common import AudioMetaData | ||
|
||
return AudioMetaData | ||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |
File renamed without changes.
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
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