pub enum TensorViewMut<'a> {
F32(TypedTensorViewMut<'a, f32>),
F64(TypedTensorViewMut<'a, f64>),
I32(TypedTensorViewMut<'a, i32>),
I64(TypedTensorViewMut<'a, i64>),
Bool(TypedTensorViewMut<'a, bool>),
C32(TypedTensorViewMut<'a, Complex<f32>>),
C64(TypedTensorViewMut<'a, Complex<f64>>),
}Expand description
Dynamic mutable borrowed tensor view.
TensorViewMut is the mutable counterpart to TensorView. It keeps the
dtype erased while preserving the typed mutable view’s shape, strides, and
offset metadata.
§Examples
use tenferro_tensor::{DType, TensorViewMut, TypedTensorViewMut};
let mut data = [1.0_f64, 2.0];
let view = TensorViewMut::F64(TypedTensorViewMut::from_slice([2], [1], 0, &mut data)?);
assert_eq!(view.dtype(), DType::F64);Variants§
F32(TypedTensorViewMut<'a, f32>)
F64(TypedTensorViewMut<'a, f64>)
I32(TypedTensorViewMut<'a, i32>)
I64(TypedTensorViewMut<'a, i64>)
Bool(TypedTensorViewMut<'a, bool>)
C32(TypedTensorViewMut<'a, Complex<f32>>)
C64(TypedTensorViewMut<'a, Complex<f64>>)
Implementations§
Source§impl<'a> TensorViewMut<'a>
impl<'a> TensorViewMut<'a>
Sourcepub fn f32(shape: &'a [usize], data: &'a mut [f32]) -> Result<Self>
pub fn f32(shape: &'a [usize], data: &'a mut [f32]) -> Result<Self>
Create a dynamic mutable view over compact column-major host data.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compact layout arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
requested shape exceeds data.
Sourcepub fn f64(shape: &'a [usize], data: &'a mut [f64]) -> Result<Self>
pub fn f64(shape: &'a [usize], data: &'a mut [f64]) -> Result<Self>
Create a dynamic mutable view over compact column-major host data.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compact layout arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
requested shape exceeds data.
Sourcepub fn i32(shape: &'a [usize], data: &'a mut [i32]) -> Result<Self>
pub fn i32(shape: &'a [usize], data: &'a mut [i32]) -> Result<Self>
Create a dynamic mutable view over compact column-major host data.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compact layout arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
requested shape exceeds data.
Sourcepub fn i64(shape: &'a [usize], data: &'a mut [i64]) -> Result<Self>
pub fn i64(shape: &'a [usize], data: &'a mut [i64]) -> Result<Self>
Create a dynamic mutable view over compact column-major host data.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compact layout arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
requested shape exceeds data.
Sourcepub fn bool(shape: &'a [usize], data: &'a mut [bool]) -> Result<Self>
pub fn bool(shape: &'a [usize], data: &'a mut [bool]) -> Result<Self>
Create a dynamic mutable view over compact column-major host data.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compact layout arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
requested shape exceeds data.
Sourcepub fn c32(shape: &'a [usize], data: &'a mut [Complex32]) -> Result<Self>
pub fn c32(shape: &'a [usize], data: &'a mut [Complex32]) -> Result<Self>
Create a dynamic mutable view over compact column-major host data.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compact layout arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
requested shape exceeds data.
Sourcepub fn c64(shape: &'a [usize], data: &'a mut [Complex64]) -> Result<Self>
pub fn c64(shape: &'a [usize], data: &'a mut [Complex64]) -> Result<Self>
Create a dynamic mutable view over compact column-major host data.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compact layout arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
requested shape exceeds data.
pub fn dtype(&self) -> DType
pub fn shape(&self) -> &[usize]
pub fn strides(&self) -> &[isize]
pub fn offset(&self) -> isize
Sourcepub fn layout_linear_offset(&self, indices: &[usize]) -> Result<usize>
pub fn layout_linear_offset(&self, indices: &[usize]) -> Result<usize>
Compute the physical element offset for a logical index.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::RankMismatch when indices
has the wrong rank, tenferro_tensor_core::ValidationError::InvalidArgument
when an index is outside its axis extent, or
tenferro_tensor_core::ValidationError::IntegerOverflow when offset
arithmetic overflows.
Sourcepub fn is_col_major_contiguous(&self) -> Result<bool>
pub fn is_col_major_contiguous(&self) -> Result<bool>
Return whether this view is compact column-major.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compactness arithmetic overflows.
pub fn layout_summary(&self) -> String
Sourcepub fn assert_col_major_contiguous(&self) -> Result<()>
pub fn assert_col_major_contiguous(&self) -> Result<()>
Assert this view is compact column-major.
§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compactness arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
view is not compact column-major.
pub fn as_read_only(&self) -> TensorView<'_>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for TensorViewMut<'a>
impl<'a> !RefUnwindSafe for TensorViewMut<'a>
impl<'a> Send for TensorViewMut<'a>
impl<'a> Sync for TensorViewMut<'a>
impl<'a> Unpin for TensorViewMut<'a>
impl<'a> UnsafeUnpin for TensorViewMut<'a>
impl<'a> !UnwindSafe for TensorViewMut<'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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more