pub struct TensorDependencyGraph {
pub nodes: HashSet<u64>,
pub edges: Vec<DependencyEdge>,
pub dirty: DirtySet,
}Expand description
Tracks data dependencies between tensors and rules, enabling incremental recomputation when tensors are updated.
Fields§
§nodes: HashSet<u64>All registered node IDs.
edges: Vec<DependencyEdge>All dependency edges.
dirty: DirtySetSet of dirty (stale) node IDs.
Implementations§
Source§impl TensorDependencyGraph
impl TensorDependencyGraph
Sourcepub fn add_edge(&mut self, edge: DependencyEdge)
pub fn add_edge(&mut self, edge: DependencyEdge)
Add a dependency edge. Also registers the from and to nodes.
Sourcepub fn remove_node(&mut self, id: u64)
pub fn remove_node(&mut self, id: u64)
Remove a node and all edges that reference it. Clears any dirty flag.
Sourcepub fn mark_dirty(&mut self, id: u64)
pub fn mark_dirty(&mut self, id: u64)
Mark id dirty and transitively propagate to all reachable dependents
via TensorOutput, RuleImplication, and SharedFact edges where
from_id == id.
Sourcepub fn recompute_order(&self) -> Vec<u64>
pub fn recompute_order(&self) -> Vec<u64>
Topological sort (Kahn’s algorithm) of dirty nodes only. Returns nodes in processing order (dependencies before dependents). On cycle detection, appends remaining nodes in arbitrary order.
Sourcepub fn dependents_of(&self, id: u64) -> Vec<u64>
pub fn dependents_of(&self, id: u64) -> Vec<u64>
Direct successors of id (edges where from_id == id), sorted ascending.
Sourcepub fn dependencies_of(&self, id: u64) -> Vec<u64>
pub fn dependencies_of(&self, id: u64) -> Vec<u64>
Direct predecessors of id (edges where to_id == id), sorted ascending.
Sourcepub fn stats(&self) -> GraphStats
pub fn stats(&self) -> GraphStats
Compute and return a statistics snapshot.
Sourcepub fn clear_all_dirty(&mut self)
pub fn clear_all_dirty(&mut self)
Clear the entire dirty set.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TensorDependencyGraph
impl RefUnwindSafe for TensorDependencyGraph
impl Send for TensorDependencyGraph
impl Sync for TensorDependencyGraph
impl Unpin for TensorDependencyGraph
impl UnsafeUnpin for TensorDependencyGraph
impl UnwindSafe for TensorDependencyGraph
Blanket Implementations§
impl<T> Allocation for T
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
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>
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>
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