Skip to content
Specular Differentiation

specular.backends.get_backend

get_backend()

Return the backend selected in the current execution context.

Parameters

None.

Returns

BackendName — "numpy", "numba", or "jax". The default is "numpy".

Notes

Reading the selection does not import the selected backend or probe optional dependencies. Selection is local to the current context; asynchronous contexts can change it independently. A fresh execution context starts with NumPy; a thread that explicitly inherits a context inherits that context's selection.

This function is also available as specular.get_backend.

Examples

import specular

specular.set_backend("numpy")
print(specular.get_backend())  # numpy

See also set_backend, use_backend, and the backend user guide.

Source code in specular/backends/_registry.py
133
134
135
136
def get_backend() -> BackendName:
    """Return the backend selected in the current execution context."""

    return _current_backend.get()