File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
import warnings
2
- import importlib
3
2
4
3
import torch
5
4
from torchaudio ._internal import module_utils as _mod_utils
6
5
7
6
8
7
def _init_extension ():
9
- ext = 'torchaudio._torchaudio'
10
- if _mod_utils .is_module_available (ext ):
11
- _init_script_module (ext )
12
- import torchaudio ._torchaudio # noqa
8
+ if _mod_utils .is_module_available ('torchaudio._torchaudio' ):
9
+ # Note this import has two purposes
10
+ # 1. to extract the path of the extension module so that
11
+ # we can initialize the script module with the path.
12
+ # 2. so that torchaudio._torchaudio is accessible in other modules.
13
+ # Look at sox_io_backend which uses `torchaudio._torchaudio.XXX`,
14
+ # assuming that the module `_torchaudio` is accessible.
15
+ import torchaudio ._torchaudio
16
+ _init_script_module (torchaudio ._torchaudio .__file__ )
13
17
else :
14
18
warnings .warn ('torchaudio C++ extension is not available.' )
15
19
16
20
17
- def _init_script_module (module ):
18
- path = importlib .util .find_spec (module ).origin
21
+ def _init_script_module (path ):
19
22
torch .classes .load_library (path )
20
23
torch .ops .load_library (path )
You can’t perform that action at this time.
0 commit comments