Struct OpenCL

Source
pub struct OpenCL(/* private fields */);
Expand description

OpenCL backend

Implementations§

Source§

impl OpenCL

Source

pub fn tensor<'a>(&'a self, data: impl IntoTensor<&'a Self>) -> Tensor<&'a Self>

Create new tensor

Source

pub fn randn(&self, shape: impl Into<Shape>, dtype: DType) -> Tensor<&Self>

Create new tensor using values from standard normal distribution

Source

pub fn uniform( &self, shape: impl Into<Shape>, range: Range<impl Scalar>, ) -> Tensor<&Self>

Create new tensor using values from uniform distribution

Source

pub fn full(&self, shape: impl Into<Shape>, value: impl Scalar) -> Tensor<&Self>

Create new tensor by repeating single value

Source

pub fn zeros(&self, shape: impl Into<Shape>, dtype: DType) -> Tensor<&Self>

Create new tensor by repeating zeroes

Source

pub fn ones(&self, shape: impl Into<Shape>, dtype: DType) -> Tensor<&Self>

Create new tensor by repeating ones

Source

pub fn eye(&self, n: usize, dtype: DType) -> Tensor<&Self>

Create eye tensor

Source

pub fn load( &self, path: impl AsRef<Path>, ) -> Result<Vec<Tensor<&OpenCL>>, ZyxError>

Load tensors from disk.

Source

pub fn plot_graph<'a, B: Backend + 'a>( &self, tensors: impl IntoIterator<Item = &'a Tensor<B>>, ) -> String

Create graph of operations between tensors in dot format for visualization

Trait Implementations§

Source§

impl Backend for &OpenCL

Source§

fn plot_graph<'a, B: Backend + 'a>( self, tensors: impl IntoIterator<Item = &'a Tensor<B>>, ) -> String

Create graph of operations between tensors in dot format for visualization
Source§

fn randn( self, shape: impl Into<Shape>, dtype: DType, ) -> Result<Tensor<Self>, ZyxError>

Create new tensor using values from standard normal distribution
Source§

fn uniform( self, shape: impl Into<Shape>, range: Range<impl Scalar>, ) -> Result<Tensor<Self>, ZyxError>

Create new tensor using values from uniform distribution
Source§

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

Get shape if tensor x
Source§

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

Get dtype of tensor x
Source§

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

Calculate derivatives of x w.r.t. sources. Returns map source id -> gradient id
Source§

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

Returns iterator over data stored in backend
Source§

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

Store iterator into backend as tensor
Source§

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

Create new tensor from given operation
Source§

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

Decrease reference count of tensor
Source§

fn retain(self, x: Id)

Increase reference count of tensor
Source§

fn tensor(self, data: impl IntoTensor<Self>) -> Result<Tensor<Self>, ZyxError>

Create new tensor
Source§

fn full( self, shape: impl Into<Shape>, value: impl Scalar, ) -> Result<Tensor<Self>, ZyxError>

Create new tensor by repeating single value
Source§

fn zeros( self, shape: impl Into<Shape>, dtype: DType, ) -> Result<Tensor<Self>, ZyxError>

Create new tensor by repeating zeroes
Source§

fn ones( self, shape: impl Into<Shape>, dtype: DType, ) -> Result<Tensor<Self>, ZyxError>

Create new tensor by repeating ones
Source§

fn eye(self, n: usize, dtype: DType) -> Result<Tensor<Self>, ZyxError>

Create eye tensor

Auto Trait Implementations§

§

impl !Freeze for OpenCL

§

impl !RefUnwindSafe for OpenCL

§

impl !Send for OpenCL

§

impl !Sync for OpenCL

§

impl Unpin for OpenCL

§

impl UnwindSafe for OpenCL

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.