pub struct ComputationGraph {
pub nodes: HashMap<usize, OpNode>,
pub adjacency: HashMap<usize, Vec<usize>>,
pub inputs: Vec<usize>,
pub outputs: Vec<usize>,
/* private fields */
}Expand description
Computation graph for optimization analysis
Fields§
§nodes: HashMap<usize, OpNode>All operation nodes
adjacency: HashMap<usize, Vec<usize>>Graph topology (adjacency list)
inputs: Vec<usize>Input nodes (no dependencies)
outputs: Vec<usize>Output nodes (no dependents)
Implementations§
Source§impl ComputationGraph
impl ComputationGraph
Sourcepub fn add_node(
&mut self,
op_type: String,
output_shape: Vec<usize>,
flops: u64,
) -> usize
pub fn add_node( &mut self, op_type: String, output_shape: Vec<usize>, flops: u64, ) -> usize
Add a node to the graph
Sourcepub fn topological_sort(&self) -> Result<Vec<usize>>
pub fn topological_sort(&self) -> Result<Vec<usize>>
Compute topological order of nodes
Sourcepub fn find_fusion_candidates(&self) -> Vec<Vec<usize>>
pub fn find_fusion_candidates(&self) -> Vec<Vec<usize>>
Find fusable operation sequences
Sourcepub fn estimate_memory_usage(&self) -> usize
pub fn estimate_memory_usage(&self) -> usize
Estimate memory usage for the graph
Sourcepub fn estimate_flops(&self) -> u64
pub fn estimate_flops(&self) -> u64
Estimate total computation cost
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ComputationGraph
impl RefUnwindSafe for ComputationGraph
impl Send for ComputationGraph
impl Sync for ComputationGraph
impl Unpin for ComputationGraph
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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