Skip to content

active_backend ΒΆ

active_backend is a proxy object that can be used as if it is the underlying numerical backend.

Examples:

>>> from funfact import use, active_backend as ab
>>> use('jax')
>>> ab.tensor([[1.0, 2.0], [2.0, 1.0]])
DeviceArray([[1., 2.],
            [2., 1.]], dtype=float32)
>>> ab.sin(3.1415926)
DeviceArray(1.509958e-07, dtype=float32, weak_type=True)
>>> ab.linspace(0, 1, 3)
DeviceArray([0. , 0.5, 1. ], dtype=float32)
>>> use('torch')
>>> ab.eye(3, dtype=ab.float16)
tensor([[1., 0., 0.],
        [0., 1., 0.],
        [0., 0., 1.]], dtype=torch.float16)
Back to top