Skip to main content

TensorMapTrait

Trait TensorMapTrait 

Source
pub trait TensorMapTrait<T>
where T: Num + Clone + Debug,
{ // Required methods fn shape(&self) -> &[usize]; fn unmap(&mut self); fn as_slice(&self) -> &[T]; fn as_mut_slice(&mut self) -> &mut [T]; fn is_writable(&self) -> bool; // Provided methods fn len(&self) -> usize { ... } fn is_empty(&self) -> bool { ... } fn size(&self) -> usize { ... } fn view(&self) -> Result<ArrayView<'_, T, Dim<IxDynImpl>>> { ... } fn view_mut(&mut self) -> Result<ArrayViewMut<'_, T, Dim<IxDynImpl>>> { ... } }

Required Methods§

Source

fn shape(&self) -> &[usize]

Get the shape of this tensor map.

Source

fn unmap(&mut self)

Unmap the tensor from memory.

Source

fn as_slice(&self) -> &[T]

Get a slice to the data in this tensor map.

Source

fn as_mut_slice(&mut self) -> &mut [T]

Get a mutable slice to the data in this tensor map.

Source

fn is_writable(&self) -> bool

Whether this mapping permits writes – i.e. whether the coherency bracket it holds will flush on release.

The single source of truth for a binding that has to advertise mutability to a foreign consumer (the Python buffer protocol’s readonly flag, say). Deriving that from the access a caller requested instead would leave the advertisement agreeing with the request while both disagreed with the mapping actually taken.

Provided Methods§

Source

fn len(&self) -> usize

Get the number of elements in this tensor map.

Source

fn is_empty(&self) -> bool

Check if the tensor map is empty.

Source

fn size(&self) -> usize

Get the size in bytes of this tensor map.

Source

fn view(&self) -> Result<ArrayView<'_, T, Dim<IxDynImpl>>>

Get an ndarray ArrayView of the tensor data.

Source

fn view_mut(&mut self) -> Result<ArrayViewMut<'_, T, Dim<IxDynImpl>>>

Get an ndarray ArrayViewMut of the tensor data.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> TensorMapTrait<T> for HostView<'_, T>
where T: Num + Clone + Debug,