backend#
- discopy.matrix.backend(name=None, _stack=['numpy'], _cache={'numpy': <discopy.matrix.NumPy object>})[source]#
Context manager for matrix backend.
- Parameters:
name (Union[Literal['numpy'], ~typing.Literal['jax'], ~typing.Literal['pytorch'], ~typing.Literal['tensorflow']]) – The name of the backend, default is
"numpy"
.
Example
>>> with backend('jax'): ... assert type(Matrix([0, 1, 1, 0], 2, 2).array).__module__\ ... == 'jaxlib.xla_extension'