Struct safetensors::tensor::TensorView
source · 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>
impl<'data> TensorView<'data>
sourcepub fn new(
dtype: Dtype,
shape: Vec<usize>,
data: &'data [u8]
) -> Result<Self, SafeTensorError>
pub fn new( dtype: Dtype, shape: Vec<usize>, data: &'data [u8] ) -> Result<Self, SafeTensorError>
Create new tensor view
sourcepub fn sliced_data(
&'data self,
slices: &[TensorIndexer]
) -> Result<SliceIterator<'data>, InvalidSlice>
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>
impl<'data> Debug for TensorView<'data>
source§impl<'data, A> IndexOp<'data, (A,)> for TensorView<'data>where
A: Into<TensorIndexer>,
impl<'data, A> IndexOp<'data, (A,)> for TensorView<'data>where
A: Into<TensorIndexer>,
source§fn slice(&'data self, index: (A,)) -> Result<SliceIterator<'data>, InvalidSlice>
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>
impl<'data, A, B> IndexOp<'data, (A, B)> for TensorView<'data>
source§fn slice(
&'data self,
index: (A, B)
) -> Result<SliceIterator<'data>, InvalidSlice>
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>
impl<'data, A, B, C> IndexOp<'data, (A, B, C)> for TensorView<'data>
source§fn slice(
&'data self,
index: (A, B, C)
) -> Result<SliceIterator<'data>, InvalidSlice>
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>,
impl<'data, A> IndexOp<'data, A> for TensorView<'data>where
A: Into<TensorIndexer>,
source§fn slice(&'data self, index: A) -> Result<SliceIterator<'data>, InvalidSlice>
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 for TensorView<'data>
impl<'data> PartialEq for TensorView<'data>
source§fn eq(&self, other: &TensorView<'data>) -> bool
fn eq(&self, other: &TensorView<'data>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<'data> View for &TensorView<'data>
impl<'data> View for &TensorView<'data>
source§impl<'data> View for TensorView<'data>
impl<'data> View for TensorView<'data>
impl<'data> Eq for TensorView<'data>
impl<'data> StructuralPartialEq for TensorView<'data>
Auto Trait Implementations§
impl<'data> Freeze for TensorView<'data>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more