Trait RuntimeBackend

Source
pub trait RuntimeBackend {
    // Required methods
    fn is_evaluated(&self, x: Id) -> bool;
    fn is_free_id(&self, x: Id) -> bool;
    fn remove(&mut self, x: Id) -> Result<(), ZyxError>;
    fn store<T: Scalar, IT>(&mut self, x: Id, iter: IT) -> Result<(), ZyxError>
       where IT: IntoIterator<Item = T>,
             IT::IntoIter: ExactSizeIterator;
    fn load<T: Scalar>(
        &mut self,
        x: Id,
        numel: usize,
    ) -> Result<Vec<T>, ZyxError>;
    fn evaluate(
        &mut self,
        rcs: BTreeMap<Id, u32>,
        order: &[Id],
        nodes: &[Node],
    ) -> Result<(), ZyxError>;
}
Expand description

RuntimeBackend is a good plug in point for backend developers. Use Runtime::new(YourOwnStructThatImplementsRuntimeBackend::new()) to write your own backend which needs to implement only evaluation of graph. Used by torch and native backends.

Required Methods§

Source

fn is_evaluated(&self, x: Id) -> bool

Is tensor x evaluated?

Source

fn is_free_id(&self, x: Id) -> bool

Check if there are no more buffers on id x

Source

fn remove(&mut self, x: Id) -> Result<(), ZyxError>

Delete all memory used by tensor x.

Source

fn store<T: Scalar, IT>(&mut self, x: Id, iter: IT) -> Result<(), ZyxError>
where IT: IntoIterator<Item = T>, IT::IntoIter: ExactSizeIterator,

Store iterator into runtime backend

Source

fn load<T: Scalar>(&mut self, x: Id, numel: usize) -> Result<Vec<T>, ZyxError>

Load evaluated tensor x.

Source

fn evaluate( &mut self, rcs: BTreeMap<Id, u32>, order: &[Id], nodes: &[Node], ) -> Result<(), ZyxError>

Evaluate tensors to_eval with given graph of nodes and recommended order of evaluation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§