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 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 f64 mutable view over compact column-major host data.
pub fn dtype(&self) -> DType
pub fn shape(&self) -> &[usize]
pub fn strides(&self) -> &[isize]
pub fn offset(&self) -> isize
pub fn layout_linear_offset(&self, indices: &[usize]) -> Result<usize>
pub fn is_col_major_contiguous(&self) -> Result<bool>
pub fn layout_summary(&self) -> String
pub fn assert_col_major_contiguous(&self) -> Result<()>
pub fn as_read_only(&self) -> TensorView<'_>
pub fn copy_from_tensor(&mut self, src: &Tensor) -> Result<()>
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
Mutably borrows from an owned value. Read more