Backend#
- class caskade.backend.Backend(backend=None)[source]#
Unified interface for array operations across torch, jax, and numpy.
Provides a single API for creating and manipulating arrays regardless of the underlying library. Methods such as
make_array,concatenate,to,sigmoid, andlogitare dynamically bound when the backend is set, delegating to the appropriate library-specific implementation.- Parameters:
backend (str, optional) – Backend name:
"torch","jax", or"numpy". IfNone, reads from theCASKADE_BACKENDenvironment variable, defaulting to"torch".
Examples
Use the module-level
backendinstance to switch backends:from caskade import backend backend.backend = "numpy" arr = backend.make_array([1.0, 2.0, 3.0])
- all(array)[source]#
Test whether all elements evaluate to
True.- Parameters:
array (ArrayLike) – Input array.
- Returns:
Scalar result;
Trueif every element is non-zero.- Return type:
ArrayLike
- any(array)[source]#
Test whether any element evaluates to
True.- Parameters:
array (ArrayLike) – Input array.
- Returns:
Scalar result;
Trueif any element is non-zero.- Return type:
ArrayLike
- property array_type#
The array class for the active backend.
Returns
torch.Tensor,jax.numpy.ndarray, ornumpy.ndarraydepending on the current backend. Useful forisinstancechecks.- Returns:
The array class used by the active backend.
- Return type:
type
Examples
isinstance(my_array, backend.array_type)
- Type:
type
- property backend#
Name of the active backend (
"torch","jax", or"numpy").- Type:
str
- exp(array)[source]#
Compute the exponential element-wise.
- Parameters:
array (ArrayLike) – Input array.
- Returns:
Element-wise exponential of the input.
- Return type:
ArrayLike