Skip to main content

Backend

Trait Backend 

Source
pub trait Backend:
    Copy
    + Default
    + Send
    + Sync
    + Debug
    + 'static
    + Sealed {
    type Scalar<T: Element>: Copy + Debug;
    type Array<T: Element>: Clone + Debug;
    type Leaf: Clone + Debug;

Show 82 methods // Required methods fn lit<T: Element>(v: T) -> Self::Scalar<T>; fn unary<T: Element>(op: UnaryOp, x: Self::Scalar<T>) -> Self::Scalar<T>; fn binary<T: Element>( op: BinaryOp, x: Self::Scalar<T>, y: Self::Scalar<T>, ) -> Self::Scalar<T>; fn compare<T: Element>( op: CompareOp, x: Self::Scalar<T>, y: Self::Scalar<T>, ) -> Self::Scalar<bool>; fn is_finite<T: Element>(x: Self::Scalar<T>) -> Self::Scalar<bool>; fn integer_pow<T: Element>(x: Self::Scalar<T>, y: i32) -> Self::Scalar<T>; fn select<T: Element>( c: Self::Scalar<bool>, t: Self::Scalar<T>, f: Self::Scalar<T>, ) -> Self::Scalar<T>; fn cast<T: Element, U: Element>(x: Self::Scalar<T>) -> Self::Scalar<U>; fn bitcast<T: Element, U: Element>(x: Self::Scalar<T>) -> Self::Scalar<U>; fn to_real<T: Element>( op: ToReal, x: Self::Scalar<T>, ) -> Self::Scalar<T::Real>; fn complex<C: Element>( re: Self::Scalar<C::Real>, im: Self::Scalar<C::Real>, ) -> Self::Scalar<C>; fn conj<T: Element>(x: Self::Scalar<T>) -> Self::Scalar<T>; fn constant<T: Element>(x: &NativeArray<T>) -> Self::Array<T>; fn shape<T: Element>(x: &Self::Array<T>) -> Shape; fn to_array<T: Element>(x: Self::Scalar<T>) -> Self::Array<T>; fn to_scalar<T: Element>(x: &Self::Array<T>) -> Self::Scalar<T>; fn a_unary<T: Element>(op: UnaryOp, x: &Self::Array<T>) -> Self::Array<T>; fn a_binary<T: Element>( op: BinaryOp, x: &Self::Array<T>, y: &Self::Array<T>, ) -> Self::Array<T>; fn a_ternary<T: Element>( op: TernaryOp, x: &Self::Array<T>, y: &Self::Array<T>, z: &Self::Array<T>, ) -> Self::Array<T>; fn a_compare<T: Element>( op: CompareOp, x: &Self::Array<T>, y: &Self::Array<T>, ) -> Self::Array<bool>; fn a_is_finite<T: Element>(x: &Self::Array<T>) -> Self::Array<bool>; fn a_integer_pow<T: Element>(x: &Self::Array<T>, y: i32) -> Self::Array<T>; fn a_cast<T: Element, U: Element>(x: &Self::Array<T>) -> Self::Array<U>; fn a_bitcast<T: Element, U: Element>(x: &Self::Array<T>) -> Self::Array<U>; fn a_to_real<T: Element>( op: ToReal, x: &Self::Array<T>, ) -> Self::Array<T::Real>; fn a_complex<C: Element>( re: &Self::Array<C::Real>, im: &Self::Array<C::Real>, ) -> Self::Array<C>; fn a_conj<T: Element>(x: &Self::Array<T>) -> Self::Array<T>; fn a_select<T: Element>( c: &Self::Array<bool>, t: &Self::Array<T>, f: &Self::Array<T>, ) -> Self::Array<T>; fn a_clamp<T: Element>( lo: &Self::Array<T>, x: &Self::Array<T>, hi: &Self::Array<T>, ) -> Self::Array<T>; fn broadcast_in_dim<T: Element>( x: &Self::Array<T>, shape: &[usize], dims: &[usize], ) -> Self::Array<T>; fn reshape<T: Element>( x: &Self::Array<T>, shape: &[usize], ) -> Self::Array<T>; fn transpose<T: Element>( x: &Self::Array<T>, perm: &[usize], ) -> Self::Array<T>; fn slice<T: Element>( x: &Self::Array<T>, start: &[usize], limit: &[usize], strides: &[usize], ) -> Self::Array<T>; fn dynamic_slice<T: Element, I: Element>( x: &Self::Array<T>, starts: &[Self::Scalar<I>], sizes: &[usize], ) -> Self::Array<T>; fn dynamic_update_slice<T: Element, I: Element>( x: &Self::Array<T>, update: &Self::Array<T>, starts: &[Self::Scalar<I>], ) -> Self::Array<T>; fn concatenate<T: Element>( xs: &[Self::Array<T>], dim: usize, ) -> Self::Array<T>; fn pad<T: Element>( x: &Self::Array<T>, value: Self::Scalar<T>, config: &[(i64, i64, usize)], ) -> Self::Array<T>; fn rev<T: Element>(x: &Self::Array<T>, dims: &[usize]) -> Self::Array<T>; fn iota<T: Element>(shape: &[usize], dim: usize) -> Self::Array<T>; fn reduce<T: Element>( op: ReduceOp, x: &Self::Array<T>, axes: &[usize], ) -> Self::Array<T>; fn arg_min_max<T: Element, I: Element>( x: &Self::Array<T>, axis: usize, max: bool, ) -> Self::Array<I>; fn sort( operands: &[Self::Leaf], dimension: usize, is_stable: bool, num_keys: usize, ) -> Vec<Self::Leaf>; fn cumulative<T: Element>( op: CumulativeOp, x: &Self::Array<T>, axis: usize, reverse: bool, ) -> Self::Array<T>; fn top_k<T: Element>( x: &Self::Array<T>, k: usize, axis: usize, ) -> (Self::Array<T>, Self::Array<i32>); fn cholesky<T: LinalgScalar>(x: &Self::Array<T>) -> Self::Array<T>; fn triangular_solve<T: LinalgScalar>( a: &Self::Array<T>, b: &Self::Array<T>, options: TriangularSolveOptions, ) -> Self::Array<T>; fn lu<T: LinalgScalar>( x: &Self::Array<T>, ) -> (Self::Array<T>, Self::Array<i32>, Self::Array<i32>); fn lu_pivots_to_permutation( pivots: &Self::Array<i32>, size: usize, ) -> Self::Array<i32>; fn qr<T: LinalgScalar>( x: &Self::Array<T>, full_matrices: bool, ) -> (Self::Array<T>, Self::Array<T>); fn qr_pivoting<T: LinalgScalar>( x: &Self::Array<T>, full_matrices: bool, ) -> (Self::Array<T>, Self::Array<T>, Self::Array<i32>); fn eigh<T: LinalgScalar>( x: &Self::Array<T>, lower: bool, sort_eigenvalues: bool, subset_by_index: Option<(usize, usize)>, algorithm: Option<EighImplementation>, ) -> (Self::Array<T>, Self::Array<T::Real>); fn eig<T: LinalgScalar>( x: &Self::Array<T>, left: bool, right: bool, enable_eigvec_derivs: bool, ) -> (Self::Array<<T as LinalgScalar>::Complex>, Option<Self::Array<<T as LinalgScalar>::Complex>>, Option<Self::Array<<T as LinalgScalar>::Complex>>); fn schur<T: LinalgScalar>( x: &Self::Array<T>, compute_schur_vectors: bool, ) -> (Self::Array<T>, Option<Self::Array<T>>); fn hessenberg<T: LinalgScalar>( x: &Self::Array<T>, ) -> (Self::Array<T>, Self::Array<T>); fn householder_product<T: LinalgScalar>( a: &Self::Array<T>, taus: &Self::Array<T>, ) -> Self::Array<T>; fn ormqr<T: LinalgScalar>( a: &Self::Array<T>, taus: &Self::Array<T>, c: &Self::Array<T>, left: bool, transpose: bool, ) -> Self::Array<T>; fn cholesky_update<T: LinalgFloat>( r: &Self::Array<T>, w: &Self::Array<T>, ) -> Self::Array<T>; fn symmetric_product<T: LinalgFloat>( a: &Self::Array<T>, c: &Self::Array<T>, alpha: f64, beta: f64, ) -> Self::Array<T>; fn tridiagonal<T: LinalgScalar>( x: &Self::Array<T>, lower: bool, ) -> (Self::Array<T>, Self::Array<T::Real>, Self::Array<T::Real>, Self::Array<T>); fn tridiagonal_solve<T: LinalgScalar>( dl: &Self::Array<T>, d: &Self::Array<T>, du: &Self::Array<T>, b: &Self::Array<T>, perturb_singular: bool, ) -> Self::Array<T>; fn svd<T: LinalgScalar>( x: &Self::Array<T>, full_matrices: bool, compute_uv: bool, subset_by_index: Option<(usize, usize)>, algorithm: Option<SvdAlgorithm>, ) -> (Self::Array<T::Real>, Option<(Self::Array<T>, Self::Array<T>)>); fn fft<T: Element, U: Element>( x: &Self::Array<T>, fft_type: FftType, fft_lengths: &[usize], ) -> Self::Array<U>; fn dot_general<T: Element, U: Element>( l: &Self::Array<T>, r: &Self::Array<T>, dims: &DotDims, precision: Precision, ) -> Self::Array<U>; fn conv_general_dilated<T: Element, U: Element>( lhs: &Self::Array<T>, rhs: &Self::Array<T>, window: &ConvWindow<'_>, dims: &ConvDims, groups: (usize, usize), precision: Precision, ) -> Self::Array<U>; fn reduce_window<T: Element>( op: ReduceOp, x: &Self::Array<T>, window: &Window<'_>, ) -> Self::Array<T>; fn select_and_scatter_add<T: Element>( source: &Self::Array<T>, operand: &Self::Array<T>, select_prim: SelectPrim, window: &Window<'_>, ) -> Self::Array<T>; fn select_and_gather_add<T: Element>( tangents: &Self::Array<T>, operand: &Self::Array<T>, select_prim: SelectPrim, window: &Window<'_>, ) -> Self::Array<T>; fn gather<T: Element, I: Element>( x: &Self::Array<T>, indices: &Self::Array<I>, dims: &GatherDims, sizes: &[usize], mode: GatherScatterMode, sorted_unique: bool, ) -> Self::Array<T>; fn scatter<T: Element, I: Element>( combine: Option<BinaryOp>, x: &Self::Array<T>, indices: &Self::Array<I>, updates: &Self::Array<T>, dims: &ScatterDims, mode: GatherScatterMode, sorted_unique: bool, ) -> Self::Array<T>; fn cond<S: Tree<Self>, R: Tree<Self>>( index: I32<Self>, branches: &[&dyn Fn(S) -> R], operand: S, ) -> R; fn while_loop<C: Tree<Self>>( cond: &dyn Fn(&C) -> Bool<Self>, body: &dyn Fn(C) -> C, init: C, ) -> C; fn scan<C: Tree<Self>, X: Tree<Self>, Y: Tree<Self>>( f: &dyn Fn(C, X) -> (C, Y), init: C, xs: X, length: usize, reverse: bool, ) -> (C, Y); fn fori_loop<C: Tree<Self>>( lo: I32<Self>, hi: I32<Self>, body: &dyn Fn(I32<Self>, C) -> C, init: C, ) -> C; fn scalar_leaf<T: Element>(x: Self::Scalar<T>) -> Self::Leaf; fn leaf_scalar<T: Element>(l: Self::Leaf) -> Self::Scalar<T>; fn array_leaf<T: Element>(x: &Self::Array<T>) -> Self::Leaf; fn leaf_array<T: Element>(l: Self::Leaf) -> Self::Array<T>; fn leaf_aval(l: &Self::Leaf) -> AVal; fn host_callback( callback: &HostCallback, args: &[Self::Leaf], outputs: &[AVal], ) -> Vec<Self::Leaf>; // Provided methods fn custom_jvp<I: Tree<Self>, O: Tree<Self>>( f: &dyn Fn(I) -> O, jvp: &dyn Fn(I, I) -> (O, O), primals: I, ) -> O { ... } fn custom_vjp<I: Tree<Self>, O: Tree<Self>, R: Tree<Self>>( f: &dyn Fn(I) -> O, fwd: &dyn Fn(I) -> (O, R), bwd: &dyn Fn(R, O) -> I, primals: I, ) -> O { ... } fn checkpoint<I: Tree<Self>, O: Tree<Self>>( f: &dyn Fn(I) -> O, input: I, ) -> O { ... }
}
Expand description

A backend: what values are and how operations run.

Programs are written generically over B: Backend with the value types Scalar and Array, which wrap B::Scalar<T> and B::Array<T>. The methods are the primitives; programs call them through the value types and the lax and jnp functions, not directly.

Required Associated Types§

Source

type Scalar<T: Element>: Copy + Debug

A scalar.

Source

type Array<T: Element>: Clone + Debug

An array.

Source

type Leaf: Clone + Debug

A leaf of a pytree, of any element type.

Required Methods§

Source

fn lit<T: Element>(v: T) -> Self::Scalar<T>

A scalar constant.

Source

fn unary<T: Element>(op: UnaryOp, x: Self::Scalar<T>) -> Self::Scalar<T>

A unary operation.

Source

fn binary<T: Element>( op: BinaryOp, x: Self::Scalar<T>, y: Self::Scalar<T>, ) -> Self::Scalar<T>

A binary operation.

Source

fn compare<T: Element>( op: CompareOp, x: Self::Scalar<T>, y: Self::Scalar<T>, ) -> Self::Scalar<bool>

A comparison.

Source

fn is_finite<T: Element>(x: Self::Scalar<T>) -> Self::Scalar<bool>

Whether the value is finite.

Source

fn integer_pow<T: Element>(x: Self::Scalar<T>, y: i32) -> Self::Scalar<T>

x^y for a static integer y.

Source

fn select<T: Element>( c: Self::Scalar<bool>, t: Self::Scalar<T>, f: Self::Scalar<T>, ) -> Self::Scalar<T>

if c { t } else { f }.

Source

fn cast<T: Element, U: Element>(x: Self::Scalar<T>) -> Self::Scalar<U>

Conversion to another element type.

Source

fn bitcast<T: Element, U: Element>(x: Self::Scalar<T>) -> Self::Scalar<U>

Reinterpretation of the bits as another type of the same size.

Source

fn to_real<T: Element>(op: ToReal, x: Self::Scalar<T>) -> Self::Scalar<T::Real>

abs, real, or imag (real and imag of complex numbers).

Source

fn complex<C: Element>( re: Self::Scalar<C::Real>, im: Self::Scalar<C::Real>, ) -> Self::Scalar<C>

A complex number from its parts (lax.complex).

Source

fn conj<T: Element>(x: Self::Scalar<T>) -> Self::Scalar<T>

The complex conjugate of a complex number.

Source

fn constant<T: Element>(x: &NativeArray<T>) -> Self::Array<T>

A constant array.

Source

fn shape<T: Element>(x: &Self::Array<T>) -> Shape

The shape of an array.

Source

fn to_array<T: Element>(x: Self::Scalar<T>) -> Self::Array<T>

A scalar as an array of rank 0.

Source

fn to_scalar<T: Element>(x: &Self::Array<T>) -> Self::Scalar<T>

An array of rank 0 as a scalar.

Source

fn a_unary<T: Element>(op: UnaryOp, x: &Self::Array<T>) -> Self::Array<T>

Elementwise unary operation.

Source

fn a_binary<T: Element>( op: BinaryOp, x: &Self::Array<T>, y: &Self::Array<T>, ) -> Self::Array<T>

Elementwise binary operation on arrays of the same shape.

Source

fn a_ternary<T: Element>( op: TernaryOp, x: &Self::Array<T>, y: &Self::Array<T>, z: &Self::Array<T>, ) -> Self::Array<T>

Elementwise ternary operation on arrays of the same shape.

Source

fn a_compare<T: Element>( op: CompareOp, x: &Self::Array<T>, y: &Self::Array<T>, ) -> Self::Array<bool>

Elementwise comparison of arrays of the same shape.

Source

fn a_is_finite<T: Element>(x: &Self::Array<T>) -> Self::Array<bool>

Elementwise is_finite.

Source

fn a_integer_pow<T: Element>(x: &Self::Array<T>, y: i32) -> Self::Array<T>

Elementwise integer_pow.

Source

fn a_cast<T: Element, U: Element>(x: &Self::Array<T>) -> Self::Array<U>

Elementwise conversion.

Source

fn a_bitcast<T: Element, U: Element>(x: &Self::Array<T>) -> Self::Array<U>

Elementwise bit reinterpretation.

Source

fn a_to_real<T: Element>(op: ToReal, x: &Self::Array<T>) -> Self::Array<T::Real>

Elementwise abs, real, or imag.

Source

fn a_complex<C: Element>( re: &Self::Array<C::Real>, im: &Self::Array<C::Real>, ) -> Self::Array<C>

Elementwise complex of arrays of the same shape.

Source

fn a_conj<T: Element>(x: &Self::Array<T>) -> Self::Array<T>

Elementwise complex conjugate.

Source

fn a_select<T: Element>( c: &Self::Array<bool>, t: &Self::Array<T>, f: &Self::Array<T>, ) -> Self::Array<T>

select_n(c, f, t): c is a scalar or has the shape of the cases.

Source

fn a_clamp<T: Element>( lo: &Self::Array<T>, x: &Self::Array<T>, hi: &Self::Array<T>, ) -> Self::Array<T>

clamp(lo, x, hi): bounds are scalars or have the shape of x.

Source

fn broadcast_in_dim<T: Element>( x: &Self::Array<T>, shape: &[usize], dims: &[usize], ) -> Self::Array<T>

broadcast_in_dim.

Source

fn reshape<T: Element>(x: &Self::Array<T>, shape: &[usize]) -> Self::Array<T>

reshape.

Source

fn transpose<T: Element>(x: &Self::Array<T>, perm: &[usize]) -> Self::Array<T>

transpose.

Source

fn slice<T: Element>( x: &Self::Array<T>, start: &[usize], limit: &[usize], strides: &[usize], ) -> Self::Array<T>

slice.

Source

fn dynamic_slice<T: Element, I: Element>( x: &Self::Array<T>, starts: &[Self::Scalar<I>], sizes: &[usize], ) -> Self::Array<T>

dynamic_slice (start indices are clamped).

Source

fn dynamic_update_slice<T: Element, I: Element>( x: &Self::Array<T>, update: &Self::Array<T>, starts: &[Self::Scalar<I>], ) -> Self::Array<T>

dynamic_update_slice (start indices are clamped).

Source

fn concatenate<T: Element>(xs: &[Self::Array<T>], dim: usize) -> Self::Array<T>

concatenate.

Source

fn pad<T: Element>( x: &Self::Array<T>, value: Self::Scalar<T>, config: &[(i64, i64, usize)], ) -> Self::Array<T>

pad.

Source

fn rev<T: Element>(x: &Self::Array<T>, dims: &[usize]) -> Self::Array<T>

rev.

Source

fn iota<T: Element>(shape: &[usize], dim: usize) -> Self::Array<T>

iota.

Source

fn reduce<T: Element>( op: ReduceOp, x: &Self::Array<T>, axes: &[usize], ) -> Self::Array<T>

A reduction over axes.

Source

fn arg_min_max<T: Element, I: Element>( x: &Self::Array<T>, axis: usize, max: bool, ) -> Self::Array<I>

argmax or argmin.

Source

fn sort( operands: &[Self::Leaf], dimension: usize, is_stable: bool, num_keys: usize, ) -> Vec<Self::Leaf>

sort of operands of the same shape (of any element types) along dimension, lexicographically by the first num_keys of them.

Source

fn cumulative<T: Element>( op: CumulativeOp, x: &Self::Array<T>, axis: usize, reverse: bool, ) -> Self::Array<T>

A cumulative reduction along axis (cumsum and the like), from the end with reverse.

Source

fn top_k<T: Element>( x: &Self::Array<T>, k: usize, axis: usize, ) -> (Self::Array<T>, Self::Array<i32>)

top_k along axis: the k largest elements in descending order, and their indices.

Source

fn cholesky<T: LinalgScalar>(x: &Self::Array<T>) -> Self::Array<T>

cholesky of a batch of matrices (see lax::linalg::cholesky).

Source

fn triangular_solve<T: LinalgScalar>( a: &Self::Array<T>, b: &Self::Array<T>, options: TriangularSolveOptions, ) -> Self::Array<T>

triangular_solve of batches of matrices.

Source

fn lu<T: LinalgScalar>( x: &Self::Array<T>, ) -> (Self::Array<T>, Self::Array<i32>, Self::Array<i32>)

lu of a batch of matrices: the factors, the pivots, and the permutation.

Source

fn lu_pivots_to_permutation( pivots: &Self::Array<i32>, size: usize, ) -> Self::Array<i32>

lu_pivots_to_permutation.

Source

fn qr<T: LinalgScalar>( x: &Self::Array<T>, full_matrices: bool, ) -> (Self::Array<T>, Self::Array<T>)

qr of a batch of matrices: q and r.

Source

fn qr_pivoting<T: LinalgScalar>( x: &Self::Array<T>, full_matrices: bool, ) -> (Self::Array<T>, Self::Array<T>, Self::Array<i32>)

qr with column pivoting of a batch of matrices: q, r, and the permutation.

Source

fn eigh<T: LinalgScalar>( x: &Self::Array<T>, lower: bool, sort_eigenvalues: bool, subset_by_index: Option<(usize, usize)>, algorithm: Option<EighImplementation>, ) -> (Self::Array<T>, Self::Array<T::Real>)

eigh of a batch of symmetric matrices: the eigenvectors and the eigenvalues (of the range subset_by_index of indices, if given).

Source

fn eig<T: LinalgScalar>( x: &Self::Array<T>, left: bool, right: bool, enable_eigvec_derivs: bool, ) -> (Self::Array<<T as LinalgScalar>::Complex>, Option<Self::Array<<T as LinalgScalar>::Complex>>, Option<Self::Array<<T as LinalgScalar>::Complex>>)

eig of a batch of general matrices: the complex eigenvalues, and the left and right eigenvectors that are requested.

Source

fn schur<T: LinalgScalar>( x: &Self::Array<T>, compute_schur_vectors: bool, ) -> (Self::Array<T>, Option<Self::Array<T>>)

schur of a batch of square matrices: t and, with compute_schur_vectors, z.

Source

fn hessenberg<T: LinalgScalar>( x: &Self::Array<T>, ) -> (Self::Array<T>, Self::Array<T>)

hessenberg of a batch of square matrices: the reduced matrices and the factors of the reflectors.

Source

fn householder_product<T: LinalgScalar>( a: &Self::Array<T>, taus: &Self::Array<T>, ) -> Self::Array<T>

householder_product of reflectors and their factors.

Source

fn ormqr<T: LinalgScalar>( a: &Self::Array<T>, taus: &Self::Array<T>, c: &Self::Array<T>, left: bool, transpose: bool, ) -> Self::Array<T>

ormqr: c times Q (or Q^H) of the reflectors.

Source

fn cholesky_update<T: LinalgFloat>( r: &Self::Array<T>, w: &Self::Array<T>, ) -> Self::Array<T>

cholesky_update: the rank-1 update by w of the upper triangular Cholesky factors r.

Source

fn symmetric_product<T: LinalgFloat>( a: &Self::Array<T>, c: &Self::Array<T>, alpha: f64, beta: f64, ) -> Self::Array<T>

symmetric_product: alpha a a^T + beta c.

Source

fn tridiagonal<T: LinalgScalar>( x: &Self::Array<T>, lower: bool, ) -> (Self::Array<T>, Self::Array<T::Real>, Self::Array<T::Real>, Self::Array<T>)

tridiagonal of a batch of Hermitian matrices: the reduced matrices, the real diagonals and off-diagonals, and the factors of the reflectors.

Source

fn tridiagonal_solve<T: LinalgScalar>( dl: &Self::Array<T>, d: &Self::Array<T>, du: &Self::Array<T>, b: &Self::Array<T>, perturb_singular: bool, ) -> Self::Array<T>

tridiagonal_solve: the solution of the tridiagonal systems of the diagonals dl, d, and du ([..., m]) with the right-hand sides b ([..., m, n]).

Source

fn svd<T: LinalgScalar>( x: &Self::Array<T>, full_matrices: bool, compute_uv: bool, subset_by_index: Option<(usize, usize)>, algorithm: Option<SvdAlgorithm>, ) -> (Self::Array<T::Real>, Option<(Self::Array<T>, Self::Array<T>)>)

svd of a batch of matrices: the singular values, and u and vt with compute_uv (of the range subset_by_index of indices, if given).

Source

fn fft<T: Element, U: Element>( x: &Self::Array<T>, fft_type: FftType, fft_lengths: &[usize], ) -> Self::Array<U>

fft of the trailing axes, from T to U (complex to complex, real to complex, or complex to real).

Source

fn dot_general<T: Element, U: Element>( l: &Self::Array<T>, r: &Self::Array<T>, dims: &DotDims, precision: Precision, ) -> Self::Array<U>

dot_general, computing in U (the operand type unless a preferred type is given).

Source

fn conv_general_dilated<T: Element, U: Element>( lhs: &Self::Array<T>, rhs: &Self::Array<T>, window: &ConvWindow<'_>, dims: &ConvDims, groups: (usize, usize), precision: Precision, ) -> Self::Array<U>

conv_general_dilated with (feature_group_count, batch_group_count) groups, computing in U (the operand type unless a preferred type is given).

Source

fn reduce_window<T: Element>( op: ReduceOp, x: &Self::Array<T>, window: &Window<'_>, ) -> Self::Array<T>

reduce_window_sum, reduce_window_max, or reduce_window_min.

Source

fn select_and_scatter_add<T: Element>( source: &Self::Array<T>, operand: &Self::Array<T>, select_prim: SelectPrim, window: &Window<'_>, ) -> Self::Array<T>

select_and_scatter_add (the window’s dilations must be 1).

Source

fn select_and_gather_add<T: Element>( tangents: &Self::Array<T>, operand: &Self::Array<T>, select_prim: SelectPrim, window: &Window<'_>, ) -> Self::Array<T>

select_and_gather_add.

Source

fn gather<T: Element, I: Element>( x: &Self::Array<T>, indices: &Self::Array<I>, dims: &GatherDims, sizes: &[usize], mode: GatherScatterMode, sorted_unique: bool, ) -> Self::Array<T>

gather.

Source

fn scatter<T: Element, I: Element>( combine: Option<BinaryOp>, x: &Self::Array<T>, indices: &Self::Array<I>, updates: &Self::Array<T>, dims: &ScatterDims, mode: GatherScatterMode, sorted_unique: bool, ) -> Self::Array<T>

A scatter: replaces (combine is None) or combines updates.

Source

fn cond<S: Tree<Self>, R: Tree<Self>>( index: I32<Self>, branches: &[&dyn Fn(S) -> R], operand: S, ) -> R

Calls branches[index] on operand; an index out of range calls the last branch, as stablehlo.case does.

Source

fn while_loop<C: Tree<Self>>( cond: &dyn Fn(&C) -> Bool<Self>, body: &dyn Fn(C) -> C, init: C, ) -> C

Repeats body while cond holds.

Source

fn scan<C: Tree<Self>, X: Tree<Self>, Y: Tree<Self>>( f: &dyn Fn(C, X) -> (C, Y), init: C, xs: X, length: usize, reverse: bool, ) -> (C, Y)

A loop over the leading dimension of the arrays of xs.

Source

fn fori_loop<C: Tree<Self>>( lo: I32<Self>, hi: I32<Self>, body: &dyn Fn(I32<Self>, C) -> C, init: C, ) -> C

for i in lo..hi { state = body(i, state) }.

Source

fn scalar_leaf<T: Element>(x: Self::Scalar<T>) -> Self::Leaf

A scalar as a pytree leaf.

Source

fn leaf_scalar<T: Element>(l: Self::Leaf) -> Self::Scalar<T>

A pytree leaf as a scalar.

Source

fn array_leaf<T: Element>(x: &Self::Array<T>) -> Self::Leaf

An array as a pytree leaf.

Source

fn leaf_array<T: Element>(l: Self::Leaf) -> Self::Array<T>

A pytree leaf as an array.

Source

fn leaf_aval(l: &Self::Leaf) -> AVal

The abstract value of a leaf.

Source

fn host_callback( callback: &HostCallback, args: &[Self::Leaf], outputs: &[AVal], ) -> Vec<Self::Leaf>

host_callback: callback on the leaves args, whose results have the types outputs.

Provided Methods§

Source

fn custom_jvp<I: Tree<Self>, O: Tree<Self>>( f: &dyn Fn(I) -> O, jvp: &dyn Fn(I, I) -> (O, O), primals: I, ) -> O

f(primals), differentiated with the rule jvp (see lax::custom_jvp).

Source

fn custom_vjp<I: Tree<Self>, O: Tree<Self>, R: Tree<Self>>( f: &dyn Fn(I) -> O, fwd: &dyn Fn(I) -> (O, R), bwd: &dyn Fn(R, O) -> I, primals: I, ) -> O

f(primals), differentiated in reverse mode with the rules fwd and bwd (see lax::custom_vjp).

Source

fn checkpoint<I: Tree<Self>, O: Tree<Self>>(f: &dyn Fn(I) -> O, input: I) -> O

f(input), whose intermediate values reverse mode recomputes (see lax::checkpoint).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§