Struct TensorView

Source
pub struct TensorView<'a, T, const N: usize, A: TensorAllocator> {
    pub storage: &'a TensorStorage<T, A>,
    pub shape: [usize; N],
    pub strides: [usize; N],
}
Expand description

A view into a tensor.

Fields§

§storage: &'a TensorStorage<T, A>

Reference to the storage held by the another tensor.

§shape: [usize; N]

The shape of the tensor.

§strides: [usize; N]

The strides of the tensor.

Implementations§

Source§

impl<'a, T, const N: usize, A: TensorAllocator + 'static> TensorView<'a, T, N, A>

Source

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

Returns the data slice of the tensor.

Source

pub fn as_ptr(&self) -> *const T

Returns the data pointer of the tensor.

Source

pub fn numel(&self) -> usize

Returns the length of the tensor.

Source

pub fn get_unchecked(&self, index: [usize; N]) -> &T

Get the element at the given index.

§Returns

A reference to the element at the given index.

§Safety

The caller must ensure that the index is within the bounds of the tensor.

Source

pub fn as_contiguous(&self) -> Tensor<T, N, CpuAllocator>
where T: Clone,

Convert the view an owned tensor with contiguous memory.

§Returns

A new Tensor instance with contiguous memory.

Auto Trait Implementations§

§

impl<'a, T, const N: usize, A> Freeze for TensorView<'a, T, N, A>

§

impl<'a, T, const N: usize, A> RefUnwindSafe for TensorView<'a, T, N, A>

§

impl<'a, T, const N: usize, A> Send for TensorView<'a, T, N, A>

§

impl<'a, T, const N: usize, A> Sync for TensorView<'a, T, N, A>

§

impl<'a, T, const N: usize, A> Unpin for TensorView<'a, T, N, A>

§

impl<'a, T, const N: usize, A> UnwindSafe for TensorView<'a, T, N, 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> 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.