def set_backend(backend_name):
"""Sets the backend for TensorLy
The backend will be set as specified and operations will used that backend
Parameters
----------
backend_name : {'mxnet', 'numpy', 'pytorch'}, default is 'numpy'
"""
global _BACKEND
_BACKEND = backend_name
# reloads tensorly.backend
importlib.reload(backend)
# reload from .backend import * (e.g. tensorly.tensor)
globals().update(
{fun: getattr(backend, fun) for n in backend.__all__} if hasattr(backend, '__all__')
else
{k: v for (k, v) in backend.__dict__.items() if not k.startswith('_')
})
评论列表
文章目录