mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
17 lines
516 B
Python
17 lines
516 B
Python
import sys
|
|
|
|
|
|
def import_module(name, path):
|
|
if sys.version_info >= (3, 5):
|
|
import importlib.util
|
|
spec = importlib.util.spec_from_file_location(name, path)
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
elif sys.version_info >= (3, 0):
|
|
from importlib.machinery import SourceFileLoader
|
|
return SourceFileLoader(name, path).load_module()
|
|
else:
|
|
import imp
|
|
return imp.load_source(name, path)
|