tensorly.tenalg.tenalg_backend_context

tenalg_backend_context(backend, local_threadsafe=False)[source]

Context manager to set the backend for TensorLy.

Parameters
backend{‘core’, ‘einsum’}
  • if ‘core’, our manually optimized implementations are used

  • if ‘einsum’, all operations are dispatched to einsum

local_threadsafebool, optional

If True, the backend will not become the default backend for all threads. Note that this only affects threads where the backend hasn’t already been explicitly set. If False (default) the backend is set for the entire session.

Examples

Set the backend to numpy globally for this thread:

>>> import tensorly.tenalg as tlg
>>> tlg.set_tenalg_backend('core')
>>> with tlg.set_tenalg_backend('einsum'):
...     pass