Skip to main content

TensorViewMut

Struct TensorViewMut 

Source
pub struct TensorViewMut<'a> { /* private fields */ }
Expand description

A mutable zero-copy view of a multi-dimensional f64 tensor.

This struct is Send but NOT Sync. It is Send because &mut [f64] is Send. It is not Sync because &mut [f64] is not Sync.

Implementations§

Source§

impl<'a> TensorViewMut<'a>

Source

pub fn new(data: &'a mut [f64], shape: Shape, storage_offset: usize) -> Self

Constructs a new mutable TensorViewMut.

§Panics

Panics if the buffer is smaller than the maximum addressable flat index.

Source

pub fn new_default(data: &'a mut [f64], shape: Shape) -> Self

Constructs a new TensorViewMut with default storage_offset of 0.

Source

pub const fn shape(&self) -> &Shape

Returns a reference to the Shape.

Source

pub const fn strides(&self) -> &Strides

Returns a reference to the Strides.

Source

pub fn is_contiguous(&self) -> bool

Returns true if this view has a contiguous layout.

Source

pub fn get_mut(&mut self, idx: &[usize]) -> Option<&mut f64>

Returns the element at the multi-dimensional index mutably.

Returns None if any index component is out of bounds.

Source

pub unsafe fn get_unchecked_mut(&mut self, idx: &[usize]) -> &mut f64

Returns a mutable reference to the element at the multi-dimensional index without bounds checking.

§Safety

The caller must guarantee that idx is a valid multi-dimensional index for this tensor view.

Source

pub fn set(&mut self, idx: &[usize], val: f64) -> bool

Sets the element at the multi-dimensional index.

Returns false if the index is out-of-bounds.

Source

pub const fn as_raw_slice(&self) -> &[f64]

Returns the flat backing buffer immutably (the entire underlying memory). Use as_slice() to get the view’s active segment.

Source

pub const fn as_raw_slice_mut(&mut self) -> &mut [f64]

Returns the flat backing buffer mutably (the entire underlying memory). Use as_slice_mut() to get the view’s active segment.

Source

pub fn as_slice(&self) -> &[f64]

Returns the active slice of this view.

§Panics

Panics if the view is not contiguous.

Source

pub fn as_slice_mut(&mut self) -> &mut [f64]

Returns the active mutable slice of this view.

§Panics

Panics if the view is not contiguous.

Source

pub fn as_view(&self) -> TensorView<'_>

Returns a read-only view of this mutable tensor.

Trait Implementations§

Source§

impl<'a> Index<&[usize]> for TensorViewMut<'a>

Source§

type Output = f64

The returned type after indexing.
Source§

fn index(&self, index: &[usize]) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, const N: usize> Index<[usize; N]> for TensorViewMut<'a>

Source§

type Output = f64

The returned type after indexing.
Source§

fn index(&self, index: [usize; N]) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> Index<(usize,)> for TensorViewMut<'a>

Source§

type Output = f64

The returned type after indexing.
Source§

fn index(&self, index: (usize,)) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> Index<(usize, usize)> for TensorViewMut<'a>

Source§

type Output = f64

The returned type after indexing.
Source§

fn index(&self, index: (usize, usize)) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> Index<(usize, usize, usize)> for TensorViewMut<'a>

Source§

type Output = f64

The returned type after indexing.
Source§

fn index(&self, index: (usize, usize, usize)) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> IndexMut<&[usize]> for TensorViewMut<'a>

Source§

fn index_mut(&mut self, index: &[usize]) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, const N: usize> IndexMut<[usize; N]> for TensorViewMut<'a>

Source§

fn index_mut(&mut self, index: [usize; N]) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IndexMut<(usize,)> for TensorViewMut<'a>

Source§

fn index_mut(&mut self, index: (usize,)) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IndexMut<(usize, usize)> for TensorViewMut<'a>

Source§

fn index_mut(&mut self, index: (usize, usize)) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IndexMut<(usize, usize, usize)> for TensorViewMut<'a>

Source§

fn index_mut(&mut self, index: (usize, usize, usize)) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,