Skip to main content

Stream

Struct Stream 

Source
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

Source

pub fn new(backend: Box<dyn Backend>) -> Self

Create a new stream with the given backend.

Source

pub fn add_constant(&self, data: Vec<f32>, meta: TensorMeta) -> NodeId

Add a constant node (data already known).

Source

pub fn add_op( &self, op: OpKind, inputs: SmallVec<[NodeId; 2]>, meta: TensorMeta, ) -> NodeId

Add an operation node to the graph.

Source

pub fn eval(&self, output: NodeId) -> Result<()>

Evaluate all nodes needed to materialize the given output.

Source

pub fn get_buffer(&self, id: NodeId) -> Option<Vec<f32>>

Get materialized buffer data for a node (must call eval first).

Source

pub fn get_node(&self, id: NodeId) -> Option<Node>

Get a clone of a graph node by ID.

Source

pub fn topo_sort(&self, outputs: &[NodeId]) -> Vec<NodeId>

Topological sort of the subgraph rooted at the given outputs.

Source

pub fn eval_count(&self) -> u64

Number of times the backend’s eval_node has been called.

Source

pub fn cache_len(&self) -> usize

Number of materialized buffers currently cached.

Trait Implementations§

Source§

impl Debug for Stream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.