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) off32,f64,c64, orc128. For complex matrices, transposes are conjugate transposes (choleskygivesx = l l^H,eightakes Hermitian matrices and gives real eigenvalues, andsvdgives real singular values andvt = v^H), and eigenvectors and singular vectors are defined up to a phase rather than a sign.
Structs§
- Conv
Options - The optional arguments of
conv_general_dilated, with JAX’s defaults: no dilation, the canonical dimension numbers (NCHW,OIHW,NCHWfor 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
paddingargument: a string or explicit(low, high)pairs. - Reduce
Op - 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: dimensioniofxbecomes dimensiondims[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 ofx; 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)ifpredholds andfalse_fn(operand)otherwise (lax.cond). OnNativethis is a real branch. - conj
- The complex conjugates (
lax.conjof complex numbers). - conv
lax.conv: a convolution of anNCHW-style input with anOIHW-style kernel.- conv_
dimension_ numbers - Converts string dimension numbers such as
("NHWC", "HWIO", "NHWC")toConvDims(lax.conv_dimension_numbers):NandCare the batch and feature dimensions of the input and the output,OandIthe 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_dilatedcomputing inU: the general convolution (seeconv_general_dilated).- convert_
element_ type - Converts to another element type.
- cos
- Cosine.
- cumlogsumexp
- The cumulative
log(sum(exp(x)))alongaxis(lax.cumlogsumexp), from the end withreverse. - cummax
- The cumulative maximum along
axis(lax.cummax), from the end withreverse. NaN propagates. - cummin
- The cumulative minimum along
axis(lax.cummin), from the end withreverse. NaN propagates. - cumprod
- The cumulative product along
axis(lax.cumprod), from the end withreverse. - cumsum
- The cumulative sum along
axis(lax.cumsum), from the end withreverse. Integers wrap around. - custom_
jvp f(primals), whose derivative in forward mode (and, by linearization, in reverse mode) is given by the rulejvp, likejax.custom_jvp.- custom_
vjp f(primals), whose derivative in reverse mode is given byfwdandbwd, likejax.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_generalwith a precision and a (wider) result type.- dynamic_
index_ in_ dim - Element
index(a run-time index) alongaxis, dropping the axis unlesskeepdims. - dynamic_
slice - A slice of
sizesat run-time start indices. Negative indices count from the end, and indices are then clamped to keep the slice in bounds. - dynamic_
update_ slice xwithupdatewritten at run-time start indices (negative indices count from the end; indices are clamped to keepupdatein 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.fftwithFftType::FftorFftType::Ifft), of lengthsfft_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. OnTrace, as in JAX, this is ascanwhen both bounds are static, and awhileotherwise.- gather
gather(the index vector is the last dimension ofindices).- 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 toa. - igammac
- The regularized upper incomplete gamma function
Q(a, x). - imag
- The imaginary parts of complex numbers (
lax.imag). - index_
in_ dim - Element
indexalongaxis, dropping the axis unlesskeepdims. - integer_
pow x^yfor a static integery.- iota
- The indices along
dimof each element ofshape. - irfft
- The complex-to-real inverse Fourier transform of the trailing axes
(
lax.fftwithFftType::Irfft): the operand hasn / 2 + 1coefficients along the last axis, and the resultnreal 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)(ma natural number). - pow
x^y.- random_
gamma_ grad - The derivative of a sample
xofGamma(a, 1)with respect toa. - 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_windowwith the monoidop(addfrom 0,maxfrom the lowest value, orminfrom 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.fftwithFftType::Rfft): the last axis hasn / 2 + 1coefficients. - 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).lengthmust match the leading dimension ofxs(and is the number of iterations whenxshas no arrays). - scan_
reverse scanfrom the end.- scatter
- Writes
updatesat run-time start indices. - scatter_
add - Adds
updatesat run-time start indices. - scatter_
max - Takes the maximum with
updatesat run-time start indices. - scatter_
min - Takes the minimum with
updatesat run-time start indices. - scatter_
mul - Multiplies by
updatesat run-time start indices. - select
if pred { on_true } else { on_false }for scalars (lax.select). Both operands are computed; usecondto skip work.- select_
array select_n(pred, on_false, on_true)withpreda scalar or of the shape of the cases (lax.selecton 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 aslax.selectin JAX.- select_
with_ operand select_withwhose sides takeoperand: 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 aslax.selectof 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.
stridesofNonemeans 1. - slice_
in_ dim x[start..limit:stride]along one axis.- sort
- Sorts along
dimension, stably (lax.sortof one operand). - sort_
key_ val - Sorts
keysalongdimension, stably, and permutesvalues(of the same shape) in the same way (lax.sort_key_val). - sort_
multi - Sorts
operands(of the same shape and element type) alongdimension, stably and lexicographically by the firstnum_keysof them, and permutes the others in the same way (lax.sortwith several operands andnum_keys, asjnp.lexsortuses it). - sqrt
- Square root.
- square
x * x.- sub
x - y.- switch
- Calls
branches[index]onoperand, with the index clamped to the branches (lax.switch). - tan
- Tangent.
- tanh
- Hyperbolic tangent.
- top_k
- The
klargest 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_fnwhilecond_fnholds (lax.while_loop). - xor
- Logical or bitwise exclusive or.
- zeta
- The Hurwitz zeta function
zeta(x, q).