pub struct TensorGraphPartitioner {
pub nodes: HashMap<u64, NodeWeight>,
pub edges: Vec<GraphEdge>,
}Expand description
Partitions a tensor computation graph into balanced subgraphs for distributed execution, minimising cross-partition edge traffic.
Fields§
§nodes: HashMap<u64, NodeWeight>All nodes, keyed by their node_id.
edges: Vec<GraphEdge>All directed edges in the graph.
Implementations§
Source§impl TensorGraphPartitioner
impl TensorGraphPartitioner
Sourcepub fn add_node(&mut self, node: NodeWeight)
pub fn add_node(&mut self, node: NodeWeight)
Inserts (or replaces) a node in the graph.
Sourcepub fn remove_node(&mut self, node_id: u64) -> bool
pub fn remove_node(&mut self, node_id: u64) -> bool
Removes a node and returns true if it was present.
Note: edges referencing the removed node are not automatically removed; callers that need edge consistency should manage this manually.
Sourcepub fn partition(&self, k: usize) -> Vec<Partition>
pub fn partition(&self, k: usize) -> Vec<Partition>
Partitions the graph into at most k parts.
§Strategy
- If
k == 0or the graph has no nodes, return an empty vector. - If
k >= node count, assign one node per partition (only non-empty partitions are returned). - Otherwise, sort all nodes by
compute_costdescending and assign each node to the partition with the lowest current total compute cost (greedy min-heap approximation via linear scan overkpartitions).
Sourcepub fn stats(&self, partitions: &[Partition]) -> PartitionStats
pub fn stats(&self, partitions: &[Partition]) -> PartitionStats
Computes statistics for the given set of partitions.
Trait Implementations§
Source§impl Debug for TensorGraphPartitioner
impl Debug for TensorGraphPartitioner
Source§impl Default for TensorGraphPartitioner
impl Default for TensorGraphPartitioner
Source§fn default() -> TensorGraphPartitioner
fn default() -> TensorGraphPartitioner
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TensorGraphPartitioner
impl RefUnwindSafe for TensorGraphPartitioner
impl Send for TensorGraphPartitioner
impl Sync for TensorGraphPartitioner
impl Unpin for TensorGraphPartitioner
impl UnsafeUnpin for TensorGraphPartitioner
impl UnwindSafe for TensorGraphPartitioner
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
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