Skip to main content

Trace

Struct Trace 

Source
pub struct Trace;
Expand description

The tracing backend: programs record their operations as IR. Values are TraceRefs into the trace in progress.

Trait Implementations§

Source§

impl Backend for Trace

Source§

type Scalar<T: Element> = TraceRef

A scalar.
Source§

type Array<T: Element> = TraceRef

An array.
Source§

type Leaf = TraceRef

A leaf of a pytree, of any element type.
Source§

fn lit<T: Element>(v: T) -> TraceRef

A scalar constant.
Source§

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

A unary operation.
Source§

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

A binary operation.
Source§

fn compare<T: Element>(op: CompareOp, x: TraceRef, y: TraceRef) -> TraceRef

A comparison.
Source§

fn is_finite<T: Element>(x: TraceRef) -> TraceRef

Whether the value is finite.
Source§

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

x^y for a static integer y.
Source§

fn select<T: Element>(c: TraceRef, t: TraceRef, f: TraceRef) -> TraceRef

if c { t } else { f }.
Source§

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

Conversion to another element type.
Source§

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

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

fn to_real<T: Element>(op: ToReal, x: TraceRef) -> TraceRef

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

fn complex<C: Element>(re: TraceRef, im: TraceRef) -> TraceRef

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

fn conj<T: Element>(x: TraceRef) -> TraceRef

The complex conjugate of a complex number.
Source§

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

A constant array.
Source§

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

The shape of an array.
Source§

fn to_array<T: Element>(x: TraceRef) -> TraceRef

A scalar as an array of rank 0.
Source§

fn to_scalar<T: Element>(x: &TraceRef) -> TraceRef

An array of rank 0 as a scalar.
Source§

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

Elementwise unary operation.
Source§

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

Elementwise binary operation on arrays of the same shape.
Source§

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

Elementwise ternary operation on arrays of the same shape.
Source§

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

Elementwise comparison of arrays of the same shape.
Source§

fn a_is_finite<T: Element>(x: &TraceRef) -> TraceRef

Elementwise is_finite.
Source§

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

Elementwise integer_pow.
Source§

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

Elementwise conversion.
Source§

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

Elementwise bit reinterpretation.
Source§

fn a_to_real<T: Element>(op: ToReal, x: &TraceRef) -> TraceRef

Elementwise abs, real, or imag.
Source§

fn a_complex<C: Element>(re: &TraceRef, im: &TraceRef) -> TraceRef

Elementwise complex of arrays of the same shape.
Source§

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

Elementwise complex conjugate.
Source§

fn a_select<T: Element>(c: &TraceRef, t: &TraceRef, f: &TraceRef) -> TraceRef

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

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

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

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

broadcast_in_dim.
Source§

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

reshape.
Source§

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

transpose.
Source§

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

slice.
Source§

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

dynamic_slice (start indices are clamped).
Source§

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

dynamic_update_slice (start indices are clamped).
Source§

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

concatenate.
Source§

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

pad.
Source§

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

rev.
Source§

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

iota.
Source§

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

A reduction over axes.
Source§

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

argmax or argmin.
Source§

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

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: &TraceRef, axis: usize, reverse: bool, ) -> TraceRef

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

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

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

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

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

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

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

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

triangular_solve of batches of matrices.
Source§

fn lu<T: LinalgScalar>(x: &TraceRef) -> (TraceRef, TraceRef, TraceRef)

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

fn lu_pivots_to_permutation(pivots: &TraceRef, size: usize) -> TraceRef

lu_pivots_to_permutation.
Source§

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

qr of a batch of matrices: q and r.
Source§

fn qr_pivoting<T: LinalgScalar>( x: &TraceRef, full_matrices: bool, ) -> (TraceRef, TraceRef, TraceRef)

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

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

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

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

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

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

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

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

householder_product of reflectors and their factors.
Source§

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

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

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

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

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

symmetric_product: alpha a a^T + beta c.
Source§

fn tridiagonal<T: LinalgScalar>( x: &TraceRef, lower: bool, ) -> (TraceRef, TraceRef, TraceRef, TraceRef)

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: &TraceRef, d: &TraceRef, du: &TraceRef, b: &TraceRef, perturb_singular: bool, ) -> TraceRef

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 eig<T: LinalgScalar>( x: &TraceRef, left: bool, right: bool, enable_eigvec_derivs: bool, ) -> (TraceRef, Option<TraceRef>, Option<TraceRef>)

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

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

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 dot_general<T: Element, U: Element>( l: &TraceRef, r: &TraceRef, dims: &DotDims, precision: Precision, ) -> TraceRef

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

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

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: &TraceRef, window: &Window<'_>, ) -> TraceRef

reduce_window_sum, reduce_window_max, or reduce_window_min.
Source§

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

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

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

select_and_gather_add.
Source§

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

gather.
Source§

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

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

fn cond<S: Tree<Self>, R: Tree<Self>>( index: I32<Trace>, 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<Trace>, body: &dyn Fn(C) -> C, init: C, ) -> C

Repeats body while cond holds.
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).
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<Trace>, hi: I32<Trace>, body: &dyn Fn(I32<Trace>, C) -> C, init: C, ) -> C

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

fn scalar_leaf<T: Element>(x: TraceRef) -> TraceRef

A scalar as a pytree leaf.
Source§

fn leaf_scalar<T: Element>(l: TraceRef) -> TraceRef

A pytree leaf as a scalar.
Source§

fn array_leaf<T: Element>(x: &TraceRef) -> TraceRef

An array as a pytree leaf.
Source§

fn leaf_array<T: Element>(l: TraceRef) -> TraceRef

A pytree leaf as an array.
Source§

fn leaf_aval(l: &TraceRef) -> AVal

The abstract value of a leaf.
Source§

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

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

impl Clone for Trace

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Trace

Source§

impl Debug for Trace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Trace

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Trace

Source§

impl Hash for Trace

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Trace

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Trace

Auto Trait Implementations§

§

impl Freeze for Trace

§

impl RefUnwindSafe for Trace

§

impl Send for Trace

§

impl Sync for Trace

§

impl Unpin for Trace

§

impl UnsafeUnpin for Trace

§

impl UnwindSafe for Trace

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.