Skip to main content

GradOp

Enum GradOp 

Source
pub enum GradOp {
Show 34 variants Input, Parameter, Add(usize, usize), Sub(usize, usize), Mul(usize, usize), Div(usize, usize), Neg(usize), MatMul(usize, usize), Sum(usize), Mean(usize), ScalarMul(usize, f64), Exp(usize), Ln(usize), StructField { parent: usize, field_index: usize, total_fields: usize, }, MapLookup { map_node: usize, key_index: usize, total_keys: usize, }, Sin(usize), Cos(usize), Sqrt(usize), Pow(usize, f64), Sigmoid(usize), Relu(usize), TanhAct(usize), Abs(usize), Log2(usize), Softmax(usize), CrossEntropy { logits: usize, targets: usize, }, LayerNorm(usize), BatchNorm(usize), Clamp { input: usize, min: f64, max: f64, }, Where { cond: usize, on_true: usize, on_false: usize, }, Reshape { input: usize, original_shape: Vec<usize>, }, TransposeOp(usize), CatOp { inputs: Vec<usize>, axis: usize, sizes: Vec<usize>, }, GatherOp { input: usize, indices: Vec<usize>, axis: usize, },
}
Expand description

Operation recorded in the computation graph.

Variants§

§

Input

§

Parameter

§

Add(usize, usize)

§

Sub(usize, usize)

§

Mul(usize, usize)

§

Div(usize, usize)

§

Neg(usize)

§

MatMul(usize, usize)

§

Sum(usize)

§

Mean(usize)

§

ScalarMul(usize, f64)

§

Exp(usize)

§

Ln(usize)

§

StructField

Gradient through struct field access: parent node, field index.

Fields

§parent: usize
§field_index: usize
§total_fields: usize
§

MapLookup

Gradient through map lookup: map node, key index in insertion order.

Fields

§map_node: usize
§key_index: usize
§total_keys: usize
§

Sin(usize)

§

Cos(usize)

§

Sqrt(usize)

§

Pow(usize, f64)

§

Sigmoid(usize)

§

Relu(usize)

§

TanhAct(usize)

§

Abs(usize)

§

Log2(usize)

§

Softmax(usize)

§

CrossEntropy

Cross-entropy loss: CrossEntropy(logits, targets)

Fields

§logits: usize
§targets: usize
§

LayerNorm(usize)

Layer normalization: LayerNorm(input); stores normalized output and std for backward

§

BatchNorm(usize)

Batch normalization: BatchNorm(input); stores normalized output and std for backward

§

Clamp

Clamp to [min, max]

Fields

§input: usize
§min: f64
§max: f64
§

Where

Conditional select: Where(condition, on_true, on_false) condition is a tensor of 0.0/1.0 masks

Fields

§cond: usize
§on_true: usize
§on_false: usize
§

Reshape

Reshape with stored original shape for backward

Fields

§input: usize
§original_shape: Vec<usize>
§

TransposeOp(usize)

Transpose (2-D)

§

CatOp

Concatenation along axis with sizes for splitting on backward

Fields

§inputs: Vec<usize>
§axis: usize
§sizes: Vec<usize>
§

GatherOp

Gather along axis: GatherOp { input, indices, axis }

Fields

§input: usize
§indices: Vec<usize>
§axis: usize

Trait Implementations§

Source§

impl Clone for GradOp

Source§

fn clone(&self) -> GradOp

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for GradOp

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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>,

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.