Commit 4463fbdf authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

[BC-Breaking] Switch to the backend dispatcher (#3241)

Summary:
This commit makes the code defaults to the backend dispatcher by default. Enabling backend dispatcher puts the FFmpeg-based I/O implementation on higher priority (if the corresponding FFmpeg is available), and allows individual function call to specify the backend.

See also https://github.com/pytorch/audio/issues/2950

Pull Request resolved: https://github.com/pytorch/audio/pull/3241

Reviewed By: hwangjeff

Differential Revision: D44709068

Pulled By: mthrok

fbshipit-source-id: 43aac3433f78a681df6669e9ac46e8ecf3beb1be
parent 2ab49e5b
from unittest.mock import patch
import torchaudio import torchaudio
from torchaudio_unittest import common_utils from torchaudio_unittest import common_utils
...@@ -8,6 +10,7 @@ class BackendSwitchMixin: ...@@ -8,6 +10,7 @@ class BackendSwitchMixin:
backend = None backend = None
backend_module = None backend_module = None
@patch("torchaudio.backend.utils._is_backend_dispatcher_enabled", lambda: False)
def test_switch(self): def test_switch(self):
torchaudio.set_audio_backend(self.backend) torchaudio.set_audio_backend(self.backend)
if self.backend is None: if self.backend is None:
......
...@@ -16,7 +16,7 @@ __all__ = [ ...@@ -16,7 +16,7 @@ __all__ = [
def _is_backend_dispatcher_enabled() -> bool: def _is_backend_dispatcher_enabled() -> bool:
return os.getenv("TORCHAUDIO_USE_BACKEND_DISPATCHER") == "1" return os.getenv("TORCHAUDIO_USE_BACKEND_DISPATCHER", default="1") == "1"
def list_audio_backends() -> List[str]: def list_audio_backends() -> List[str]:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment