Skip to main content

GradNode

Struct GradNode 

Source
pub struct GradNode<Op: GraphOp> { /* private fields */ }
Expand description

Backward computation node for eager reverse-mode AD.

A GradNode records one primal operation, the stable input aliases used to replay that operation during backward, the user-visible output keys that can receive cotangent seeds, and the edges to parent eager values.

§Examples

use tidu::{GradEdge, GradNode};

let node = GradNode::new(
    op,
    input_aliases,
    output_keys,
    saved_forward_values,
    vec![GradEdge::new(parent_node, input_key, true)],
);

Implementations§

Source§

impl<Op: GraphOp> GradNode<Op>

Source

pub fn new( op: Op, primal_in_keys: Vec<GlobalValKey<Op>>, primal_out_keys: Vec<GlobalValKey<Op>>, saved_data: HashMap<GlobalValKey<Op>, Arc<Op::Operand>>, input_edges: Vec<GradEdge<Op>>, ) -> Self

Create a grad node and validate the shape of its eager AD metadata.

primal_in_keys must contain GlobalValKey::Input aliases. The eager backward path linearizes one operation at a time and rebuilds those aliases as fragment inputs.

§Examples
let node = tidu::GradNode::new(
    op,
    input_aliases,
    output_keys,
    saved_data,
    input_edges,
);
Source

pub fn op(&self) -> &Op

The primal operation recorded by this node.

Source

pub fn primal_in_keys(&self) -> &[GlobalValKey<Op>]

Stable input aliases used for single-op backward replay.

Source

pub fn primal_out_keys(&self) -> &[GlobalValKey<Op>]

User-visible output keys, one per primal output slot.

Source

pub fn saved_data(&self) -> &HashMap<GlobalValKey<Op>, Arc<Op::Operand>>

Saved concrete primal input and derived output values.

Source

pub fn input_edges(&self) -> &[GradEdge<Op>]

Edges to the eager values that provided this node’s inputs.

Auto Trait Implementations§

§

impl<Op> Freeze for GradNode<Op>
where Op: Freeze,

§

impl<Op> RefUnwindSafe for GradNode<Op>
where Op: RefUnwindSafe, <Op as GraphOp>::InputKey: RefUnwindSafe, <Op as GraphOp>::Operand: RefUnwindSafe,

§

impl<Op> Send for GradNode<Op>

§

impl<Op> Sync for GradNode<Op>

§

impl<Op> Unpin for GradNode<Op>
where Op: Unpin, <Op as GraphOp>::InputKey: Unpin,

§

impl<Op> UnsafeUnpin for GradNode<Op>
where Op: UnsafeUnpin,

§

impl<Op> UnwindSafe for GradNode<Op>
where Op: UnwindSafe + RefUnwindSafe, <Op as GraphOp>::InputKey: UnwindSafe + RefUnwindSafe, <Op as GraphOp>::Operand: RefUnwindSafe,

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

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.