pub struct F32Tensor { /* private fields */ }Expand description
Owned finite f32 tensor values plus optional JSON metadata.
Implementations§
Source§impl F32Tensor
impl F32Tensor
Sourcepub fn new(shape: TensorShape, values: Vec<f32>) -> Result<Self>
pub fn new(shape: TensorShape, values: Vec<f32>) -> Result<Self>
Creates an owned tensor when shape and finite-value validation pass.
Sourcepub fn from_dims(dims: impl Into<Vec<usize>>, values: Vec<f32>) -> Result<Self>
pub fn from_dims(dims: impl Into<Vec<usize>>, values: Vec<f32>) -> Result<Self>
Creates an owned tensor from raw dimensions and values.
Sourcepub fn shape(&self) -> &TensorShape
pub fn shape(&self) -> &TensorShape
Borrows the checked tensor shape.
Sourcepub fn into_values(self) -> Vec<f32>
pub fn into_values(self) -> Vec<f32>
Consumes the tensor and returns its contiguous values.
Sourcepub fn metadata(&self) -> &BTreeMap<String, Value>
pub fn metadata(&self) -> &BTreeMap<String, Value>
Borrows optional transport metadata attached to the tensor.
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 tensor.
Sourcepub fn set_metadata(
&mut self,
key: impl Into<String>,
value: impl Into<Value>,
) -> &mut Self
pub fn set_metadata( &mut self, key: impl Into<String>, value: impl Into<Value>, ) -> &mut Self
Inserts or replaces one metadata entry in place.
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 as_view(&self) -> F32TensorView<'_>
pub fn as_view(&self) -> F32TensorView<'_>
Borrows this tensor as a validated view that shares the value slice.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for F32Tensor
impl<'de> Deserialize<'de> for F32Tensor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for F32Tensor
Auto Trait Implementations§
impl Freeze for F32Tensor
impl RefUnwindSafe for F32Tensor
impl Send for F32Tensor
impl Sync for F32Tensor
impl Unpin for F32Tensor
impl UnsafeUnpin for F32Tensor
impl UnwindSafe for F32Tensor
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