pub struct TensorView<'data> { /* private fields */ }
Expand description

A view of a Tensor within the file. Contains references to data within the full byte-buffer And is thus a readable view of a single tensor

Implementations§

source§

impl<'data> TensorView<'data>

source

pub fn new( dtype: Dtype, shape: Vec<usize>, data: &'data [u8] ) -> Result<Self, SafeTensorError>

Create new tensor view

source

pub fn dtype(&self) -> Dtype

The current tensor dtype

source

pub fn shape(&'data self) -> &'data [usize]

The current tensor shape

source

pub fn data(&self) -> &'data [u8]

The current tensor byte-buffer

source

pub fn sliced_data( &'data self, slices: &[TensorIndexer] ) -> Result<SliceIterator<'data>, InvalidSlice>

The various pieces of the data buffer according to the asked slice

Trait Implementations§

source§

impl<'data> Debug for TensorView<'data>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'data, A> IndexOp<'data, (A,)> for TensorView<'data>where A: Into<TensorIndexer>,

source§

fn slice(&'data self, index: (A,)) -> Result<SliceIterator<'data>, InvalidSlice>

Returns a slicing iterator which are the chunks of data necessary to reconstruct the desired tensor.
source§

impl<'data, A, B> IndexOp<'data, (A, B)> for TensorView<'data>where A: Into<TensorIndexer>, B: Into<TensorIndexer>,

source§

fn slice( &'data self, index: (A, B) ) -> Result<SliceIterator<'data>, InvalidSlice>

Returns a slicing iterator which are the chunks of data necessary to reconstruct the desired tensor.
source§

impl<'data, A, B, C> IndexOp<'data, (A, B, C)> for TensorView<'data>where A: Into<TensorIndexer>, B: Into<TensorIndexer>, C: Into<TensorIndexer>,

source§

fn slice( &'data self, index: (A, B, C) ) -> Result<SliceIterator<'data>, InvalidSlice>

Returns a slicing iterator which are the chunks of data necessary to reconstruct the desired tensor.
source§

impl<'data, A> IndexOp<'data, A> for TensorView<'data>where A: Into<TensorIndexer>,

source§

fn slice(&'data self, index: A) -> Result<SliceIterator<'data>, InvalidSlice>

Returns a slicing iterator which are the chunks of data necessary to reconstruct the desired tensor.
source§

impl<'data> PartialEq<TensorView<'data>> for TensorView<'data>

source§

fn eq(&self, other: &TensorView<'data>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'data> View for &TensorView<'data>

source§

fn dtype(&self) -> Dtype

The Dtype of the tensor
source§

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

The shape of the tensor
source§

fn data(&self) -> Cow<'_, [u8]>

The data of the tensor
source§

fn data_len(&self) -> usize

The length of the data, in bytes. This is necessary as this might be faster to get than data().len() for instance for tensors residing in GPU.
source§

impl<'data> View for TensorView<'data>

source§

fn dtype(&self) -> Dtype

The Dtype of the tensor
source§

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

The shape of the tensor
source§

fn data(&self) -> Cow<'_, [u8]>

The data of the tensor
source§

fn data_len(&self) -> usize

The length of the data, in bytes. This is necessary as this might be faster to get than data().len() for instance for tensors residing in GPU.
source§

impl<'data> Eq for TensorView<'data>

source§

impl<'data> StructuralEq for TensorView<'data>

source§

impl<'data> StructuralPartialEq for TensorView<'data>

Auto Trait Implementations§

§

impl<'data> RefUnwindSafe for TensorView<'data>

§

impl<'data> Send for TensorView<'data>

§

impl<'data> Sync for TensorView<'data>

§

impl<'data> Unpin for TensorView<'data>

§

impl<'data> UnwindSafe for TensorView<'data>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.