pub struct F32TensorView<'a> { /* private fields */ }Expand description
Borrowed finite f32 tensor values with owned shape and metadata.
Implementations§
Source§impl<'a> F32TensorView<'a>
impl<'a> F32TensorView<'a>
Sourcepub fn new(shape: TensorShape, values: &'a [f32]) -> Result<Self>
pub fn new(shape: TensorShape, values: &'a [f32]) -> Result<Self>
Creates a borrowed tensor view when shape and values are compatible.
Sourcepub fn from_dims(dims: impl Into<Vec<usize>>, values: &'a [f32]) -> Result<Self>
pub fn from_dims(dims: impl Into<Vec<usize>>, values: &'a [f32]) -> Result<Self>
Creates a borrowed tensor view from raw dimensions and values.
Sourcepub fn shape(&self) -> &TensorShape
pub fn shape(&self) -> &TensorShape
Borrows the checked tensor shape.
Sourcepub fn metadata(&self) -> &BTreeMap<String, Value>
pub fn metadata(&self) -> &BTreeMap<String, Value>
Borrows optional transport metadata attached to the view.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<Value>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<Value>, ) -> Self
Attaches one metadata entry and returns the updated view.
Sourcepub fn reshape(self, dims: impl Into<Vec<usize>>) -> Result<Self>
pub fn reshape(self, dims: impl Into<Vec<usize>>) -> Result<Self>
Changes only the shape metadata after verifying the element count is unchanged.
Sourcepub fn into_owned(self) -> Result<F32Tensor>
pub fn into_owned(self) -> Result<F32Tensor>
Copies the borrowed values into an owned tensor while preserving metadata.
Trait Implementations§
Source§impl<'a> Clone for F32TensorView<'a>
impl<'a> Clone for F32TensorView<'a>
Source§fn clone(&self) -> F32TensorView<'a>
fn clone(&self) -> F32TensorView<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for F32TensorView<'a>
impl<'a> Debug for F32TensorView<'a>
Source§impl<'a> PartialEq for F32TensorView<'a>
impl<'a> PartialEq for F32TensorView<'a>
Source§fn eq(&self, other: &F32TensorView<'a>) -> bool
fn eq(&self, other: &F32TensorView<'a>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<'a> StructuralPartialEq for F32TensorView<'a>
Auto Trait Implementations§
impl<'a> Freeze for F32TensorView<'a>
impl<'a> RefUnwindSafe for F32TensorView<'a>
impl<'a> Send for F32TensorView<'a>
impl<'a> Sync for F32TensorView<'a>
impl<'a> Unpin for F32TensorView<'a>
impl<'a> UnsafeUnpin for F32TensorView<'a>
impl<'a> UnwindSafe for F32TensorView<'a>
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