Skip to main content

Expr

Struct Expr 

Source
pub struct Expr<E>(pub E);
Expand description

A wrapper around an expression node, providing operator overloading and builder methods.

Tuple Fields§

§0: E

Implementations§

Source§

impl<L> Expr<L>

Source

pub fn relu(self) -> Expr<UnaryExpr<Relu, L>>

Apply ReLU to this expression.

Source

pub fn sigmoid(self) -> Expr<UnaryExpr<Sigmoid, L>>

Apply sigmoid to this expression.

Source

pub fn tanh(self) -> Expr<UnaryExpr<Tanh, L>>

Apply tanh to this expression.

Source

pub fn gelu(self) -> Expr<UnaryExpr<Gelu, L>>

Apply exact GELU to this expression.

Source

pub fn gelu_grad(self) -> Expr<UnaryExpr<GeluGrad, L>>

Apply exact GELU gradient to this expression.

Source

pub fn sin(self) -> Expr<UnaryExpr<Sin, L>>

Apply sine to this expression.

Source

pub fn cos(self) -> Expr<UnaryExpr<Cos, L>>

Apply cosine to this expression.

Source

pub fn exp(self) -> Expr<UnaryExpr<Exp, L>>

Apply exponential to this expression.

Source

pub fn log(self) -> Expr<UnaryExpr<Log, L>>

Apply natural log to this expression.

Source

pub fn abs(self) -> Expr<UnaryExpr<Abs, L>>

Apply absolute value to this expression.

Source

pub fn sqrt(self) -> Expr<UnaryExpr<Sqrt, L>>

Apply square root to this expression.

Source

pub fn silu(self) -> Expr<UnaryExpr<Silu, L>>

Apply SiLU to this expression.

Source

pub fn silu_grad(self) -> Expr<UnaryExpr<SiluGrad, L>>

Apply SiLU gradient to this expression.

Source

pub fn mish(self) -> Expr<UnaryExpr<Mish, L>>

Apply Mish to this expression.

Source

pub fn mish_grad(self) -> Expr<UnaryExpr<MishGrad, L>>

Apply Mish gradient to this expression.

Source

pub fn elu(self) -> Expr<UnaryExpr<Elu, L>>

Apply ELU to this expression.

Source

pub fn elu_grad(self) -> Expr<UnaryExpr<EluGrad, L>>

Apply ELU gradient to this expression.

Source

pub fn softplus(self) -> Expr<UnaryExpr<Softplus, L>>

Apply softplus to this expression.

Source

pub fn softplus_grad(self) -> Expr<UnaryExpr<SoftplusGrad, L>>

Apply softplus gradient to this expression.

Source

pub fn gelu_tanh(self) -> Expr<UnaryExpr<GeluTanh, L>>

Apply tanh-approximation GELU to this expression.

Source

pub fn gelu_tanh_grad(self) -> Expr<UnaryExpr<GeluTanhGrad, L>>

Apply tanh-approximation GELU gradient to this expression.

Source

pub fn recip(self) -> Expr<UnaryExpr<Recip, L>>

Apply reciprocal (1/x) to this expression.

Source

pub fn sign(self) -> Expr<UnaryExpr<Sign, L>>

Apply signum to this expression.

Source

pub fn floor(self) -> Expr<UnaryExpr<Floor, L>>

Apply floor to this expression.

Source

pub fn ceil(self) -> Expr<UnaryExpr<Ceil, L>>

Apply ceil to this expression.

Source

pub fn round(self) -> Expr<UnaryExpr<Round, L>>

Apply round to this expression.

Source

pub fn trunc(self) -> Expr<UnaryExpr<Trunc, L>>

Apply truncation toward zero to this expression.

Trait Implementations§

Source§

impl<L, R> Add<Expr<R>> for Expr<L>

Source§

type Output = Expr<BinaryExpr<Add, L, R>>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Expr<R>) -> Self::Output

Performs the + operation. Read more
Source§

impl<L, T: Scalar> Add<T> for Expr<L>

Source§

type Output = Expr<BinaryExpr<Add, L, ScalarVal<T>>>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<E: Clone> Clone for Expr<E>

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<E: Copy> Copy for Expr<E>

Source§

impl<E: CpuExprNode<T, B>, T: Scalar, B: CpuBackend> CpuExprNode<T, B> for Expr<E>

Source§

unsafe fn eval_cpu(&self, coords: &[usize]) -> T

Evaluate the node at the specified coordinates. Read more
Source§

unsafe fn eval_cpu_flat(&self, idx: usize) -> T

Evaluate the node at a flat index for contiguous tensors. Read more
Source§

impl<L, R> Div<Expr<R>> for Expr<L>

Source§

type Output = Expr<BinaryExpr<Div, L, R>>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Expr<R>) -> Self::Output

Performs the / operation. Read more
Source§

impl<L, T: Scalar> Div<T> for Expr<L>

Source§

type Output = Expr<BinaryExpr<Div, L, ScalarVal<T>>>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<E: ExprNode<T, B>, T: Scalar, B: ComputeBackend> ExprNode<T, B> for Expr<E>

Source§

fn collect_inputs<'expression>( &'expression self, list: &mut Vec<&'expression Tensor<T, B>>, )

Collect all input tensors borrowed by this node.
Source§

fn to_shader_expr( &self, input_map: &HashMap<*const Tensor<T, B>, usize>, ) -> String

Emit a WGSL expression string referencing the inputs by index.
Source§

fn shape(&self) -> Result<Option<Shape>, BackendError>

Returns the output shape of this node, or None for scalar nodes. Read more
Source§

fn is_contiguous_and_same_shape(&self, out_shape: &[usize]) -> bool

Returns true if this node is contiguous and matches out_shape.
Source§

impl<L, R> Mul<Expr<R>> for Expr<L>

Source§

type Output = Expr<BinaryExpr<Mul, L, R>>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Expr<R>) -> Self::Output

Performs the * operation. Read more
Source§

impl<L, T: Scalar> Mul<T> for Expr<L>

Source§

type Output = Expr<BinaryExpr<Mul, L, ScalarVal<T>>>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<L> Neg for Expr<L>

Source§

type Output = Expr<UnaryExpr<Neg, L>>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<L, R> Sub<Expr<R>> for Expr<L>

Source§

type Output = Expr<BinaryExpr<Sub, L, R>>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Expr<R>) -> Self::Output

Performs the - operation. Read more
Source§

impl<L, T: Scalar> Sub<T> for Expr<L>

Source§

type Output = Expr<BinaryExpr<Sub, L, ScalarVal<T>>>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<E> Forget for Expr<E>

§

impl<E> Freeze for Expr<E>
where E: Freeze,

§

impl<E> Move for Expr<E>

§

impl<E> RefUnwindSafe for Expr<E>
where E: RefUnwindSafe,

§

impl<E> Send for Expr<E>
where E: Send,

§

impl<E> Sync for Expr<E>
where E: Sync,

§

impl<E> Unpin for Expr<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for Expr<E>
where E: UnsafeUnpin,

§

impl<E> UnwindSafe for Expr<E>
where E: UnwindSafe,

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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
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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more