Skip to main content

Module lax

Module lax 

Source
Expand description

Operations following jax.lax: control flow, and primitives on arrays with strict shapes and types (operands of binary operations have the same shape).

Modules§

linalg
Linear algebra following jax.lax.linalg: decompositions of batches of matrices ([..., m, n], batch dimensions first) of f32, f64, c64, or c128. For complex matrices, transposes are conjugate transposes (cholesky gives x = l l^H, eigh takes Hermitian matrices and gives real eigenvalues, and svd gives real singular values and vt = v^H), and eigenvectors and singular vectors are defined up to a phase rather than a sign.

Structs§

ConvOptions
The optional arguments of conv_general_dilated, with JAX’s defaults: no dilation, the canonical dimension numbers (NCHW, OIHW, NCHW for two spatial dimensions), one group, and the default precision.

Enums§

FftType
The kind of a Fourier transform (lax.FftType).
Padding
Padding of a convolution or a windowed reduction, as JAX’s padding argument: a string or explicit (low, high) pairs.
ReduceOp
A reduction.

Functions§

abs
|x|.
add
x + y.
and
Logical or bitwise and.
argmax
The index of the largest element along axis (NaN counts as largest; ties take the first index).
argmin
The index of the smallest element along axis.
atan2
atan2(x, y).
bessel_i0e
The exponentially scaled modified Bessel function of order 0, exp(-|x|) I0(x).
bessel_i1e
The exponentially scaled modified Bessel function of order 1, exp(-|x|) I1(x).
betainc
The regularized incomplete beta function I_x(a, b).
bitcast_convert_type
Reinterprets the bits as another element type of the same size.
broadcast_in_dim
Broadcasts to shape: dimension i of x becomes dimension dims[i].
cbrt
Cube root.
ceil
Round up.
checkpoint
f(input), whose intermediate values reverse-mode differentiation recomputes from the inputs instead of storing (jax.checkpoint).
clamp
clamp(lo, x, hi): bounds are scalars or of the shape of x; propagates NaN.
complex
Complex numbers from their real and imaginary parts (lax.complex; the shapes must be equal).
concatenate
Joins arrays along dim.
cond
Calls true_fn(operand) if pred holds and false_fn(operand) otherwise (lax.cond). On Native this is a real branch.
conj
The complex conjugates (lax.conj of complex numbers).
conv
lax.conv: a convolution of an NCHW-style input with an OIHW-style kernel.
conv_dimension_numbers
Converts string dimension numbers such as ("NHWC", "HWIO", "NHWC") to ConvDims (lax.conv_dimension_numbers): N and C are the batch and feature dimensions of the input and the output, O and I the output and input feature dimensions of the kernel, and other characters name spatial dimensions, which are ordered as in the kernel’s spec.
conv_general_dilated
lax.conv_general_dilated: a convolution with strides, padding, input and kernel dilation, any layout, and feature or batch groups, with the result in the operands’ type.
conv_general_dilated_with
lax.conv_general_dilated computing in U: the general convolution (see conv_general_dilated).
convert_element_type
Converts to another element type.
cos
Cosine.
cumlogsumexp
The cumulative log(sum(exp(x))) along axis (lax.cumlogsumexp), from the end with reverse.
cummax
The cumulative maximum along axis (lax.cummax), from the end with reverse. NaN propagates.
cummin
The cumulative minimum along axis (lax.cummin), from the end with reverse. NaN propagates.
cumprod
The cumulative product along axis (lax.cumprod), from the end with reverse.
cumsum
The cumulative sum along axis (lax.cumsum), from the end with reverse. Integers wrap around.
custom_jvp
f(primals), whose derivative in forward mode (and, by linearization, in reverse mode) is given by the rule jvp, like jax.custom_jvp.
custom_vjp
f(primals), whose derivative in reverse mode is given by fwd and bwd, like jax.custom_vjp.
digamma
The digamma function, the derivative of lgamma.
div
x / y.
dot_general
dot_general, with the result in the operands’ type.
dot_general_with
dot_general with a precision and a (wider) result type.
dynamic_index_in_dim
Element index (a run-time index) along axis, dropping the axis unless keepdims.
dynamic_slice
A slice of sizes at run-time start indices. Negative indices count from the end, and indices are then clamped to keep the slice in bounds.
dynamic_update_slice
x with update written at run-time start indices (negative indices count from the end; indices are clamped to keep update in bounds).
eq
x == y.
erf
The error function.
erf_inv
The inverse error function.
erfc
The complementary error function, 1 - erf(x).
exp
e^x.
expm1
e^x - 1.
fft
A complex-to-complex Fourier transform of the trailing axes (lax.fft with FftType::Fft or FftType::Ifft), of lengths fft_lengths (one to three, equal to the trailing dimensions). The inverse divides by the number of elements transformed.
floor
Round down.
fori_loop
for i in lo..hi { state = body(i, state) } (lax.fori_loop). The bounds are Rust integers or values. On Trace, as in JAX, this is a scan when both bounds are static, and a while otherwise.
gather
gather (the index vector is the last dimension of indices).
ge
x >= y.
gt
x > y.
igamma
The regularized lower incomplete gamma function P(a, x).
igamma_grad_a
The derivative of igamma(a, x) with respect to a.
igammac
The regularized upper incomplete gamma function Q(a, x).
imag
The imaginary parts of complex numbers (lax.imag).
index_in_dim
Element index along axis, dropping the axis unless keepdims.
integer_pow
x^y for a static integer y.
iota
The indices along dim of each element of shape.
irfft
The complex-to-real inverse Fourier transform of the trailing axes (lax.fft with FftType::Irfft): the operand has n / 2 + 1 coefficients along the last axis, and the result n real numbers.
is_finite
Whether each element is finite.
le
x <= y.
lgamma
The logarithm of the absolute value of the gamma function.
log
Natural logarithm.
log1p
log(1 + x).
logistic
The logistic sigmoid.
lt
x < y.
max
Maximum, propagating NaN.
min
Minimum, propagating NaN.
mul
x * y.
ne
x != y.
neg
-x.
not
Logical or bitwise not.
or
Logical or bitwise or.
pad
Pads with value: (low, high, interior) per dimension.
polygamma
The polygamma function psi^(m)(x) (m a natural number).
pow
x^y.
random_gamma_grad
The derivative of a sample x of Gamma(a, 1) with respect to a.
real
The real parts of complex numbers (lax.real).
reduce_max
The maximum over axes.
reduce_min
The minimum over axes.
reduce_sum
Sums over axes.
reduce_window
lax.reduce_window with the monoid op (add from 0, max from the lowest value, or min from the highest), with base and window dilations (None: 1). String padding is resolved for the operand’s shape and the dilated window, as JAX does.
reduce_window_max
The maximum over windows, propagating NaN (lax.reduce_window(x, -inf, lax.max, ...)).
reduce_window_min
The minimum over windows, propagating NaN (lax.reduce_window(x, inf, lax.min, ...)).
reduce_window_sum
Sums over windows (lax.reduce_window(x, 0, lax.add, ...)).
rem
Remainder of truncated division.
reshape
Changes the shape, keeping the elements in row-major order.
rev
Reverses dimensions.
rfft
The real-to-complex Fourier transform of the trailing axes (lax.fft with FftType::Rfft): the last axis has n / 2 + 1 coefficients.
round
Round, halfway cases away from zero (lax.round’s default).
rsqrt
1 / sqrt(x).
scan
A loop over the leading dimension of the arrays of xs: returns the final carry and the outputs stacked along a new leading dimension (lax.scan). length must match the leading dimension of xs (and is the number of iterations when xs has no arrays).
scan_reverse
scan from the end.
scatter
Writes updates at run-time start indices.
scatter_add
Adds updates at run-time start indices.
scatter_max
Takes the maximum with updates at run-time start indices.
scatter_min
Takes the minimum with updates at run-time start indices.
scatter_mul
Multiplies by updates at run-time start indices.
select
if pred { on_true } else { on_false } for scalars (lax.select). Both operands are computed; use cond to skip work.
select_array
select_n(pred, on_false, on_true) with pred a scalar or of the shape of the cases (lax.select on arrays).
select_with
select_tree(pred, &on_true(), &on_false()), computing only the chosen side when the backend can branch (natively); traced, both sides are computed and selected, which gives the same IR as lax.select in JAX.
select_with_operand
select_with whose sides take operand: natively, the chosen side gets it by value (so that it can update arrays in place, without the copy that a shared array needs); traced, each side gets a copy, and the results are selected (the same IR as lax.select of both sides in JAX).
shift_left
x << y.
shift_right_arithmetic
x >> y, filling with the sign bit.
shift_right_logical
x >> y, filling with zeros.
sign
The sign.
sin
Sine.
slice
A static slice. strides of None means 1.
slice_in_dim
x[start..limit:stride] along one axis.
sort
Sorts along dimension, stably (lax.sort of one operand).
sort_key_val
Sorts keys along dimension, stably, and permutes values (of the same shape) in the same way (lax.sort_key_val).
sort_multi
Sorts operands (of the same shape and element type) along dimension, stably and lexicographically by the first num_keys of them, and permutes the others in the same way (lax.sort with several operands and num_keys, as jnp.lexsort uses it).
sqrt
Square root.
square
x * x.
sub
x - y.
switch
Calls branches[index] on operand, with the index clamped to the branches (lax.switch).
tan
Tangent.
tanh
Hyperbolic tangent.
top_k
The k largest elements along the last axis in descending order, and their indices (lax.top_k). Equal elements keep their order; floats are ordered as -NaN < -inf < ... < -0.0 < 0.0 < ... < inf < NaN (by their bits, as XLA does).
transpose
Permutes dimensions.
while_loop
Repeats body_fn while cond_fn holds (lax.while_loop).
xor
Logical or bitwise exclusive or.
zeta
The Hurwitz zeta function zeta(x, q).