pub struct ComputeGraph {
pub nodes: Vec<GraphNode>,
pub outputs: Vec<NodeId>,
}Expand description
A directed acyclic compute graph. Acyclic by construction: ComputeGraph::push
only accepts inputs that reference already-added nodes (or EXTERNAL), so insertion
order is a valid topological order. nodes[i].out.producer == NodeId(i).
Fields§
§nodes: Vec<GraphNode>§outputs: Vec<NodeId>Implementations§
Source§impl ComputeGraph
impl ComputeGraph
Sourcepub fn push(
&mut self,
op: OpNode,
ins: &[TensorRef],
out_shape: Shape,
out_dtype: DType,
sched: Schedule,
) -> Result<TensorRef, ForgeError>
pub fn push( &mut self, op: OpNode, ins: &[TensorRef], out_shape: Shape, out_dtype: DType, sched: Schedule, ) -> Result<TensorRef, ForgeError>
Append a node and return a TensorRef to its output. Enforces:
- at most
MAX_INinputs; - every non-external input references an already-added node (→ acyclic, and insertion order is topological);
- each input edge’s declared shape/dtype matches its producer’s output (shape
compatibility) — runtime-parameterized dims (
0) are treated as wildcards.
Sourcepub fn mark_output(&mut self, t: TensorRef)
pub fn mark_output(&mut self, t: TensorRef)
Mark a tensor as a graph output.
Trait Implementations§
Source§impl Clone for ComputeGraph
impl Clone for ComputeGraph
Source§fn clone(&self) -> ComputeGraph
fn clone(&self) -> ComputeGraph
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ComputeGraph
impl Debug for ComputeGraph
Source§impl Default for ComputeGraph
impl Default for ComputeGraph
Source§fn default() -> ComputeGraph
fn default() -> ComputeGraph
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ComputeGraph
impl RefUnwindSafe for ComputeGraph
impl Send for ComputeGraph
impl Sync for ComputeGraph
impl Unpin for ComputeGraph
impl UnsafeUnpin for ComputeGraph
impl UnwindSafe for ComputeGraph
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.