Skip to main content

ExprGraph

Struct ExprGraph 

Source
pub struct ExprGraph { /* private fields */ }
Expand description

Expression graph with optimized performance. Forward evaluation is pure; reuse an EvalTape to cache intermediates explicitly.

Implementations§

Source§

impl ExprGraph

Source

pub fn new() -> Self

Source

pub fn input(&mut self, name: String) -> NodeId

Source

pub fn constant(&mut self, value: Float) -> NodeId

Source

pub fn operation<I>(&mut self, op: Op, inputs: I) -> NodeId
where I: AsRef<[NodeId]>,

Source

pub fn output(&mut self, node: NodeId) -> NodeId

Source

pub fn fwd_tape(&self) -> EvalTape

Allocate a forward-mode tape sized for this graph. Reuse it to avoid allocations between runs.

Source

pub fn tape(&self) -> ReverseTape

Allocate a reverse-mode tape sized for this graph.

Source

pub fn reverse_tape(&self) -> ReverseTape

Source

pub fn input_names(&self) -> &[String]

Source

pub fn eval_fwd(&self, inputs: &[Float]) -> Vec<(Float, Vec<Float>)>

Pure forward evaluation that allocates its own tape. Suitable for single-shot calls. Returns a value and per-input gradient vector for each output.

Source

pub fn eval_fwd_with_tape( &self, inputs: &[Float], tape: &mut EvalTape, ) -> Vec<(Float, Vec<Float>)>

Forward evaluation that reuses the provided tape to cache intermediates. Returns a value and per-input gradient vector for each output.

Source

pub fn eval_fwd_one(&self, inputs: &[Float]) -> (Float, Vec<Float>)

Source

pub fn eval_fwd_one_with_tape( &self, inputs: &[Float], tape: &mut EvalTape, ) -> (Float, Vec<Float>)

Source

pub fn eval_fwd_named( &self, inputs: &[Float], ) -> Vec<(Float, Vec<(String, Float)>)>

Source

pub fn eval_fwd_named_with_tape( &self, inputs: &[Float], tape: &mut EvalTape, ) -> Vec<(Float, Vec<(String, Float)>)>

Source

pub fn eval(&self, inputs: &[Float]) -> Vec<(Float, Vec<Float>)>

Reverse-mode evaluation that allocates its own tape. Suitable for single-shot calls. Returns a value and per-input gradient vector for each output.

Source

pub fn eval_with_tape( &self, inputs: &[Float], tape: &mut ReverseTape, ) -> Vec<(Float, Vec<Float>)>

Reverse-mode evaluation that reuses the provided tape to cache intermediates. Returns a value and per-input gradient vector for each output.

Source

pub fn eval_for( &self, inputs: &[Float], outputs: &[NodeId], ) -> Vec<(Float, Vec<Float>)>

Reverse-mode evaluation for a selected set of outputs.

Source

pub fn eval_for_with_tape( &self, inputs: &[Float], outputs: &[NodeId], tape: &mut ReverseTape, ) -> Vec<(Float, Vec<Float>)>

Reverse-mode evaluation for a selected set of outputs with a reusable tape.

Source

pub fn eval_one(&self, inputs: &[Float]) -> (Float, Vec<Float>)

Source

pub fn eval_one_with_tape( &self, inputs: &[Float], tape: &mut ReverseTape, ) -> (Float, Vec<Float>)

Source

pub fn eval_named(&self, inputs: &[Float]) -> Vec<(Float, Vec<(String, Float)>)>

Source

pub fn eval_named_with_tape( &self, inputs: &[Float], tape: &mut ReverseTape, ) -> Vec<(Float, Vec<(String, Float)>)>

Source

pub fn eval_named_for( &self, inputs: &[Float], outputs: &[NodeId], ) -> Vec<(Float, Vec<(String, Float)>)>

Source

pub fn eval_named_for_with_tape( &self, inputs: &[Float], outputs: &[NodeId], tape: &mut ReverseTape, ) -> Vec<(Float, Vec<(String, Float)>)>

Trait Implementations§

Source§

impl Debug for ExprGraph

Source§

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

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

impl Default for ExprGraph

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V