Enum zyx_core::node::Node

source ·
pub enum Node {
Show 25 variants Detach(Id), Leaf(Shape, DType), Uniform(Shape, DType), Cast(Id, DType), Neg(Id), ReLU(Id), Sin(Id), Cos(Id), Ln(Id), Exp(Id), Tanh(Id), Sqrt(Id), Add(Id, Id), Sub(Id, Id), Mul(Id, Id), Div(Id, Id), Pow(Id, Id), Cmplt(Id, Id), Where(Id, Id, Id), Reshape(Id, Shape), Expand(Id, Shape), Permute(Id, Axes, Shape), Pad(Id, Box<[(i64, i64)]>, Shape), Sum(Id, Axes, Shape), Max(Id, Axes, Shape),
}
Expand description

Node representing different possible tensors

Variants§

§

Detach(Id)

Detach tensor from tape

§

Leaf(Shape, DType)

Leaf that is guaranteed to be evaluated

§

Uniform(Shape, DType)

Uniform initializer for range 0..1

§

Cast(Id, DType)

Cast to dtype unary op

§

Neg(Id)

Neg unary op

§

ReLU(Id)

ReLU unary op

§

Sin(Id)

Sine unary op

§

Cos(Id)

Cosine unary op

§

Ln(Id)

Natural logarithm unary op

§

Exp(Id)

Exp unary op

§

Tanh(Id)

Hyperbolic tangent unary op

§

Sqrt(Id)

Square root unary op

§

Add(Id, Id)

Addition binary op

§

Sub(Id, Id)

Subtraction binary op

§

Mul(Id, Id)

Multiplication binary op

§

Div(Id, Id)

Division binary op

§

Pow(Id, Id)

Exponentiation binary op

§

Cmplt(Id, Id)

Compare less than binary op

§

Where(Id, Id, Id)

Where op

§

Reshape(Id, Shape)

Reshape movement op

§

Expand(Id, Shape)

Expand movement op

§

Permute(Id, Axes, Shape)

Permute movement op

§

Pad(Id, Box<[(i64, i64)]>, Shape)

Pad movement op

§

Sum(Id, Axes, Shape)

Sum reduce op

§

Max(Id, Axes, Shape)

Max reduce op

Implementations§

source§

impl Node

source

pub const fn num_parameters(&self) -> u8

Get number of parameters of self. This method does not allocate.

source

pub const fn parameters(&self) -> impl Iterator<Item = Id>

Get all parameters of self. This method does not allocate.

source

pub fn flop(&self, nodes: &[Node]) -> usize

Get number of operations necessary to calculate this node

source

pub fn parameters_contain(&self, nid: Id) -> bool

Check if parameters of self contains nid.

source

pub fn is_reduce(&self) -> bool

Is this reduce node? (sum or max)

Trait Implementations§

source§

impl Debug for Node

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

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
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.

source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.