pub struct Stream { /* private fields */ }Expand description
A computation stream binding a graph to a backend.
Operations on tensors add nodes to the stream’s graph lazily.
Calling eval() topologically sorts and evaluates pending nodes.
Implementations§
Source§impl Stream
impl Stream
Sourcepub fn add_constant(&self, data: Vec<f32>, meta: TensorMeta) -> NodeId
pub fn add_constant(&self, data: Vec<f32>, meta: TensorMeta) -> NodeId
Add a constant node (data already known).
Sourcepub fn add_op(
&self,
op: OpKind,
inputs: SmallVec<[NodeId; 2]>,
meta: TensorMeta,
) -> NodeId
pub fn add_op( &self, op: OpKind, inputs: SmallVec<[NodeId; 2]>, meta: TensorMeta, ) -> NodeId
Add an operation node to the graph.
Sourcepub fn eval(&self, output: NodeId) -> Result<()>
pub fn eval(&self, output: NodeId) -> Result<()>
Evaluate all nodes needed to materialize the given output.
Sourcepub fn get_buffer(&self, id: NodeId) -> Option<Vec<f32>>
pub fn get_buffer(&self, id: NodeId) -> Option<Vec<f32>>
Get materialized buffer data for a node (must call eval first).
Sourcepub fn topo_sort(&self, outputs: &[NodeId]) -> Vec<NodeId>
pub fn topo_sort(&self, outputs: &[NodeId]) -> Vec<NodeId>
Topological sort of the subgraph rooted at the given outputs.
Sourcepub fn eval_count(&self) -> u64
pub fn eval_count(&self) -> u64
Number of times the backend’s eval_node has been called.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Stream
impl !RefUnwindSafe for Stream
impl Send for Stream
impl Sync for Stream
impl Unpin for Stream
impl UnsafeUnpin for Stream
impl !UnwindSafe for Stream
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