Skip to main content

Input

Enum Input 

Source
pub enum Input<'a> {
    Owned(Mat),
    Borrowed {
        values: &'a [f32],
        dimensions: &'a [usize],
    },
    View(&'a MatView<'a>),
}
Expand description

One input of a request.

The variant decides what the call does with the storage. Input::Owned transfers a tensor the crate created or cloned, Input::Borrowed reads FP32 values where the caller keeps them, and Input::View reads a region of an existing tensor without copying it. A borrowed entry is only valid for the call that receives it, which is why Net::infer and Net::infer_into bound the borrow themselves.

Variants§

§

Owned(Mat)

Tensor storage this request owns.

§

Borrowed

Unpacked FP32 values and their extents, read where the caller keeps them.

Fields

§values: &'a [f32]

Values in channel-plane order.

§dimensions: &'a [usize]

Extents in ncnn order, without the batch dimension.

§

View(&'a MatView<'a>)

A tensor sub view, which keeps no storage of its own.

Implementations§

Source§

impl<'a> Input<'a>

Source

pub fn borrowed(values: &'a [f32], dimensions: &'a [usize]) -> Self

Reads FP32 values the caller keeps, without copying them.

Source

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

Reads a tensor sub view, without copying it.

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.
Source§

impl<'a> From<(&'a [f32], &'a [usize])> for Input<'a>

Source§

fn from((values, dimensions): (&'a [f32], &'a [usize])) -> Self

Converts to this type from the input type.
Source§

impl From<Mat> for Input<'_>

Source§

fn from(mat: Mat) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

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

§

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

§

impl<'a> Freeze for Input<'a>

§

impl<'a> RefUnwindSafe for Input<'a>

§

impl<'a> Unpin for Input<'a>

§

impl<'a> UnsafeUnpin for Input<'a>

§

impl<'a> UnwindSafe for Input<'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.