Skip to main content

Crate ruxla_kernels

Crate ruxla_kernels 

Source
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, and zeta.
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 $v to the Vec of 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 $t set 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 bfloat16 format.
f16
A 16-bit floating point type implementing the IEEE 754-2008 standard binary16 a.k.a “half” format.

Enums§

BinaryOp
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.
CompareOp
A comparison.
DType
The element type of a value.
DTypeKind
The kind of an element type.
TernaryOp
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§

BufferElement
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, and c128.
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 convert on CPU:
compare
Compares two values (floats follow IEEE 754: comparisons with NaN are false, except Ne).
integer_pow
x^y for an integer exponent, by repeated squaring in the same order as JAX’s lowering of integer_pow (which fixes the rounding of floats). Negative exponents take the reciprocal at the end.

Type Aliases§

c64
A complex number made of two f32s (complex64).
c128
A complex number made of two f64s (complex128).