Skip to main content

Layer

Struct Layer 

Source
pub struct Layer { /* private fields */ }
Expand description

A single CPU layer with automatic pipeline cleanup.

Implementations§

Source§

impl Layer

Source

pub fn new(name: &str, options: Options) -> Result<Self>

Creates a built-in CPU layer.

Source

pub unsafe fn load_param(&mut self, parameters: &ParamDict) -> Result<()>

Loads layer-specific parameters before pipeline creation.

§Safety

Parameters must satisfy the selected layer’s shape, type, and range contract.

Source

pub unsafe fn load_model(&mut self, model: ncnn_modelbin_t) -> Result<()>

Loads weights through an upstream ModelBin.

§Safety

The model and its reader must be valid for this call. Borrowed weight storage and allocator dependencies must remain valid until the layer is destroyed.

Source

pub unsafe fn create_pipeline(&mut self) -> Result<()>

Creates a pipeline after parameter and weight loading.

§Safety

Required parameters and weights must be loaded according to the layer contract.

Source

pub unsafe fn forward(&mut self, input: &Mat) -> Result<Mat>

Executes a one-input, one-output CPU layer.

§Safety

The layer must support this forward form and the input’s dimensions, scalar format, and packing. The native callback must initialize the output elements.

Source

pub fn as_raw(&self) -> ncnn_layer_t

Borrows the native layer handle.

Trait Implementations§

Source§

impl Drop for Layer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for Layer

§

impl !RefUnwindSafe for Layer

§

impl !Send for Layer

§

impl !Sync for Layer

§

impl Unpin for Layer

§

impl UnsafeUnpin for Layer

§

impl UnwindSafe for Layer

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.