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.

Object Safety§

This trait is not object safe.

Implementors§