Struct zyx_core::runtime::Runtime

source ·
pub struct Runtime<R: RuntimeBackend> { /* private fields */ }
Expand description

Runtime with autograd engine. This runtime uses Node enum as representation of tensors.

Implementations§

source§

impl<R: RuntimeBackend> Runtime<R>

source

pub fn new(runtime_backend: R) -> Self

Initialize new runtime.

source

pub fn randn(&mut self, shape: Shape, dtype: DType) -> Result<Id, ZyxError>

Create tensor initialized from normal distribution.

source

pub fn uniform<T: Scalar>( &mut self, shape: Shape, range: Range<T> ) -> Result<Id, ZyxError>

Create uniform tensor from range low..high

source

pub fn shape(&self, x: Id) -> &Shape

Get shape of tensor x

source

pub fn dtype(&self, x: Id) -> DType

Get dtype of tensor x

source

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

Load tensor x

source

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

Store iterator into runtime as tensor

source

pub fn push(&mut self, node: Node) -> Result<Id, ZyxError>

Push new Node into the graph creating new tensor. This function does ZERO verification that the node is correct, but it optimizes out useless operations (like reshaping to the same shape)

source

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

Decrease reference count of x. If x’s reference count reaches zero, this function will delete x and release all of it’s predecessors in the graph.

source

pub fn retain(&mut self, x: Id)

Increase reference count of tensor x.

source

pub fn debug_graph(&self)

Debug print all nodes

source

pub fn evaluate(&mut self, nodes: BTreeSet<Id>) -> Result<(), ZyxError>

Evaluate specified nodes.

source

pub fn plot_graph_dot(&self, ids: &[Id]) -> String

Plot dot graph in dot format between given nodes

source

pub fn backward( &mut self, x: Id, sources: &BTreeSet<Id> ) -> Result<BTreeMap<Id, Id>, ZyxError>

Common autograd engine, currently used by all backends.

Auto Trait Implementations§

§

impl<R> Freeze for Runtime<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Runtime<R>
where R: RefUnwindSafe,

§

impl<R> Send for Runtime<R>
where R: Send,

§

impl<R> Sync for Runtime<R>
where R: Sync,

§

impl<R> Unpin for Runtime<R>
where R: Unpin,

§

impl<R> UnwindSafe for Runtime<R>
where R: UnwindSafe,

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>,

§

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>,

§

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.