Expand description
The semantics of ruxla’s operations: elementwise and array computations on typed slices, following XLA’s CPU behavior where StableHLO leaves it to the implementation.
The native backend and the IR interpreter both call these functions, so they agree by construction; XLA is the independent reference.
§Examples
use ruxla_kernels::{BinaryOp, Ops, cast};
// Integer division by zero gives -1, as in XLA, instead of panicking.
assert_eq!(i32::binary(BinaryOp::Div, 7, 0), -1);
// Float to integer conversions saturate, and NaN becomes 0.
assert_eq!(cast::<f32, i32>(f32::NAN), 0);Modules§
- array
- Array operations on row-major buffers.
- elementwise
- Elementwise operations on slices.
- fft
- Fast Fourier transforms (
lax.fft), with XLA’s conventions: the forward transforms are not normalized, and the inverse transforms divide by the number of elements transformed. - linalg
- Linear algebra on batches of row-major matrices: Cholesky, triangular solves, LU, QR, symmetric eigendecomposition, and SVD.
- random
- The hash of JAX’s random numbers.
- special
- Special functions:
lgamma,digamma,erf,erfc, the exponentially scaled Bessel functions, the incomplete gamma and beta functions,polygamma, andzeta. - window
- Convolutions and windowed reductions on row-major buffers, with XLA’s semantics.
Macros§
- with_
buffer - Evaluates an expression with the typed elements of a
Buffer: binds$vto theVecof the buffer’s element type in each arm, so the body is instantiated for every element type. - with_
dtype - Evaluates an expression with a type parameter
$tset to the Rust type of an element type.
Structs§
- Complex
- A complex number with real and imaginary parts of type
F. - bf16
- A 16-bit floating point type implementing the
bfloat16format. - f16
- A 16-bit floating point type implementing the IEEE 754-2008 standard
binary16a.k.a “half” format.
Enums§
- Binary
Op - An elementwise operation with two operands of the same type and a result of that type.
- Buffer
- The elements of an array of any element type.
- Compare
Op - A comparison.
- DType
- The element type of a value.
- DType
Kind - The kind of an element type.
- Ternary
Op - An elementwise operation with three operands of the same type and a result of that type.
- UnaryOp
- An elementwise operation with one operand and a result of the same type.
- Value
- A value of any element type, widened without loss: the common form through which conversions go.
Traits§
- Buffer
Element - Wrapping and viewing typed vectors in
Buffers. - Element
- A Rust type that is an element type of ruxla. It is implemented for
bool, the integer types,f16,bf16,f32,f64,c64, andc128. - Ops
- Elementwise operations on one element type. Calling an operation that
the type does not support (see
UnaryOp::supports) panics; callers check the types first.
Functions§
- cast
- Converts between element types with the semantics of XLA’s
converton CPU: - compare
- Compares two values (floats follow IEEE 754: comparisons with NaN are
false, except
Ne). - integer_
pow x^yfor an integer exponent, by repeated squaring in the same order as JAX’s lowering ofinteger_pow(which fixes the rounding of floats). Negative exponents take the reciprocal at the end.