Skip to main content

MatView

Struct MatView 

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

A read-only alias of part of a tensor.

A view shares the source storage: it neither copies nor extends the source’s lifetime, so it borrows the tensor it came from and cannot be transferred into an extractor. Submitting one through Extractor::input copies, because an alias keeps no storage of its own.

Implementations§

Source§

impl MatView<'_>

Source

pub fn info(&self) -> TensorInfo

Returns the borrowed tensor metadata.

Source

pub fn as_mat(&self) -> &Mat

Borrows the aliased tensor.

The tensor keeps no storage of its own, so it cannot be transferred into an extractor, and submitting it through Extractor::input copies. The borrowed form accepts it without a copy: Input::view bounds the borrow to one request, and Extractor::input_borrowed carries the lifetime rules of every other borrowed input, which requires light mode off.

Source

pub fn is_empty(&self) -> bool

Reports whether the region holds no elements.

Source

pub fn as_f32_slice(&self) -> Result<&[f32]>

Borrows contiguous FP32 storage without padding.

Source

pub fn channel_f32(&self, channel: usize) -> Result<&[f32]>

Borrows one channel of this region, skipping inter-channel padding.

Source

pub fn to_f32(&self) -> Result<Vec<f32>>

Copies logical FP32 elements into a new vector.

Source

pub fn to_f32_into(&self, buffer: &mut Vec<f32>) -> Result<()>

Replaces the vector contents with logical FP32 elements.

Source

pub fn deep_clone(&self) -> Result<Mat>

Copies the region into a tensor with independent storage.

Trait Implementations§

Source§

impl<'a, 'view: 'a> From<&'a MatView<'view>> for Input<'a>

Source§

fn from(view: &'a MatView<'view>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> !Send for MatView<'a>

§

impl<'a> !Sync for MatView<'a>

§

impl<'a> Freeze for MatView<'a>

§

impl<'a> RefUnwindSafe for MatView<'a>

§

impl<'a> Unpin for MatView<'a>

§

impl<'a> UnsafeUnpin for MatView<'a>

§

impl<'a> UnwindSafe for MatView<'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 = !

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

fn try_from(value: U) -> Result<T, !>

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.