pub struct ComputationGraph {
pub nodes: HashMap<String, GraphNode>,
pub inputs: Vec<String>,
pub outputs: Vec<String>,
pub metadata: HashMap<String, String>,
pub cid: Option<Cid>,
}Expand description
Computation graph
Fields§
§nodes: HashMap<String, GraphNode>Graph nodes (node ID -> node)
inputs: Vec<String>Input node IDs
outputs: Vec<String>Output node IDs
metadata: HashMap<String, String>Graph metadata
cid: Option<Cid>Graph CID (if stored in IPFS)
Implementations§
Source§impl ComputationGraph
impl ComputationGraph
Sourcepub fn mark_input(&mut self, node_id: String)
pub fn mark_input(&mut self, node_id: String)
Mark a node as an input
Sourcepub fn mark_output(&mut self, node_id: String)
pub fn mark_output(&mut self, node_id: String)
Mark a node as an output
Sourcepub fn topological_sort(&self) -> Result<Vec<String>, GraphError>
pub fn topological_sort(&self) -> Result<Vec<String>, GraphError>
Get topological order of nodes
Sourcepub fn extract_subgraph(
&self,
output_ids: &[String],
) -> Result<ComputationGraph, GraphError>
pub fn extract_subgraph( &self, output_ids: &[String], ) -> Result<ComputationGraph, GraphError>
Extract a subgraph containing only the specified output nodes
Sourcepub fn optimize_cse(&mut self) -> usize
pub fn optimize_cse(&mut self) -> usize
Optimize the graph using common subexpression elimination
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Count the number of nodes
Sourcepub fn input_count(&self) -> usize
pub fn input_count(&self) -> usize
Get the number of inputs
Sourcepub fn output_count(&self) -> usize
pub fn output_count(&self) -> usize
Get the number of outputs
Sourcepub fn propagate_shapes(&mut self) -> Result<(), GraphError>
pub fn propagate_shapes(&mut self) -> Result<(), GraphError>
Propagate shapes through the graph (shape inference) This method performs a topological traversal and infers output shapes for all nodes
Sourcepub fn validate(&self) -> Result<(), GraphError>
pub fn validate(&self) -> Result<(), GraphError>
Validate graph structure and shapes
Sourcepub fn estimate_memory(&self) -> usize
pub fn estimate_memory(&self) -> usize
Get memory footprint estimate for the graph
Trait Implementations§
Source§impl Clone for ComputationGraph
impl Clone for ComputationGraph
Source§fn clone(&self) -> ComputationGraph
fn clone(&self) -> ComputationGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ComputationGraph
impl Debug for ComputationGraph
Source§impl Default for ComputationGraph
impl Default for ComputationGraph
Source§impl<'de> Deserialize<'de> for ComputationGraph
impl<'de> Deserialize<'de> for ComputationGraph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ComputationGraph
impl RefUnwindSafe for ComputationGraph
impl Send for ComputationGraph
impl Sync for ComputationGraph
impl Unpin for ComputationGraph
impl UnwindSafe for ComputationGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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