Skip to main content

Crate ruxla_core

Crate ruxla_core 

Source
Expand description

The frontend of ruxla: programs written once, generic over a Backend, run as native code (Native) or become IR (Trace).

Re-exports§

pub use jnp::ALL;
pub use jnp::Axes;
pub use random::Key;

Modules§

indexing
NumPy-style indexing: Array::i reads elements and Array::at returns an array with some elements updated, like x[...] and x.at[...].set(...) in JAX.
jnp
Functions following jax.numpy, with NumPy’s broadcasting.
lax
Operations following jax.lax: control flow, and primitives on arrays with strict shapes and types (operands of binary operations have the same shape).
nn
Functions of jax.nn that environments and models use.
prelude
The items most programs use: use ruxla_core::prelude::*; (or ruxla::prelude::*).
random
Random numbers following jax.random, bit for bit.
runtime
The XLA runtime: PJRT clients and the cache of compiled functions.
scipy
Functions following jax.scipy.

Structs§

Array
An array of element type T on backend B, with a shape known at run time (and fixed within a traced program).
Complex
A complex number with real and imaginary parts of type F.
ExternFn
A StableHLO module written by another program, called like a function from traced programs: XLA links it with the caller and compiles them together (extern_call). The interpreter and the native backend cannot run it, so programs that call it run with jit.
Grad
See grad.
Jit
A function compiled with XLA; see jit.
Jvp
See jvp.
Native
The native backend: programs run as native code compiled by rustc. Scalars are Rust values, arrays are NativeArrays, and control flow is real branches and loops.
NativeArray
An array of the Native backend: its elements (shared if large) and a shape.
OnDevice
A pytree whose arrays are on the device of the runtime’s platform, made by device_put or returned by Jit::call_on_device.
Scalar
A scalar of element type T on backend B.
Shape
The dimension sizes of an array, in row-major order.
Trace
The tracing backend: programs record their operations as IR. Values are TraceRefs into the trace in progress.
TraceRef
A value of the Trace backend: an entry of a trace frame.
Traced
A traced program: the IR and the structures of its input and output.
ValueAndGrad
See value_and_grad.
VjpFn
See vjp.
Vmap
A batched function; see vmap.
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§

DType
The element type of a value.
ExternError
An error from reading a module for ExternFn.
ToReal
An operation with a real result from (complex) numbers.
TreeDef
A description of a pytree’s structure, for writing it out to other languages (the field names of structs, for example).

Traits§

ArrayLike
Something that can be an operand of an array operation: an array, a scalar, or a Rust value.
Backend
A backend: what values are and how operations run.
ComplexFloat
Element types that are complex numbers, whose parts are Floats.
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.
Float
Element types that are floating point numbers.
Inexact
Element types that are floats or complex numbers (NumPy’s inexact). They have the transcendental functions that complex numbers share with floats (exp, ln, sqrt, sin, …), and derivatives.
Int
Element types that are integers.
LinalgFloat
The real element types of linear algebra (lax::linalg, jnp::linalg): f32 and f64.
LinalgScalar
The element types of the linear algebra primitives (lax::linalg): f32, f64, c64, and c128. The eigenvalues of eigh and the singular values of svd have the real type Real.
Num
Element types that are real numbers (integers and floats; not bool or complex numbers).
Numeric
Element types that are numbers: integers, floats, and complex numbers (NumPy’s number). They have arithmetic.
RealFloat
The floats that complex numbers are made of (f32 and f64), with their complex type (the result of rfft).
Tree
A pytree: a structure of scalars and arrays on backend B.

Functions§

device_put
Copies a pytree of Native values to the device of the runtime’s platform.
grad
Returns a function that computes the gradient of f(params, args) with respect to params, like jax.grad. See value_and_grad for what f takes and returns (auxiliary outputs are dropped).
interpret
Traces f and runs the IR with the interpreter on input, returning the output as Native values. Useful to check that a program gives the same results natively and as IR.
is_tracing
Returns whether a trace is in progress on this thread.
jit
Returns f compiled with XLA, like jax.jit.
jvp
Returns a function that computes f(primals) and its derivative in the direction of tangents (forward mode), like jax.jvp.
leaves
Returns the leaves of a pytree.
leaves_as
Returns the leaves of a pytree as arrays of element type T (scalars as arrays of rank 0), for code that treats every leaf alike, such as optimizers.
make_ir
Returns the IR of f traced on values shaped like example, like jax.make_jaxpr.
pure_callback
Calls the native function f on input from code of any backend, as JAX’s pure_callback: natively, f runs directly; in a trace, the call is a host_callback equation, which the interpreter and ruxla’s XLA runtime (CPU, and CUDA around copies to the host) run by calling f on the host. like gives the structure and types of the results (its values are not used). Code that cannot be written for every backend (external libraries, arbitrary data structures) can thus run inside jit, vmap (a loop over the examples), and the programs of environments.
select_tree
Selects on_true or on_false leaf by leaf (jax.tree.map of lax.select).
trace
Traces f on Trace values shaped like example (a Native pytree) and returns the IR with the structures of the input and output.
unflatten_arrays
Builds a pytree with the structure of like from arrays, one per leaf (the inverse of leaves_as).
value_and_grad
Returns a function that computes f(params, args) and its gradient with respect to params, like jax.value_and_grad(f, has_aux=True).
vjp
Returns a function that computes f(primals) and the cotangents of the inputs for given cotangents of the outputs (reverse mode), like calling the function that jax.vjp returns.
vmap
Returns f batched over examples, like jax.vmap with every input and output batched at dimension 0.

Type Aliases§

Bool
A bool scalar.
C64
A c64 (complex64) scalar.
C128
A c128 (complex128) scalar.
F32
An f32 scalar.
F64
An f64 scalar.
I32
An i32 scalar.
I64
An i64 scalar.
U8
A u8 scalar.
U32
A u32 scalar.
c64
A complex number made of two f32s (complex64).
c128
A complex number made of two f64s (complex128).

Derive Macros§

Tree
Derives Tree<B> for a struct with named fields whose first type parameter is the backend B.