Skip to main content

ParamDict

Struct ParamDict 

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

Owns a native parameter dictionary for standalone layers.

Implementations§

Source§

impl ParamDict

Source

pub fn new() -> Result<Self>

Creates an empty dictionary.

Source

pub fn set_int(&mut self, id: i32, value: i32) -> Result<()>

Stores an integer parameter at the given id.

Source

pub fn set_float(&mut self, id: i32, value: f32) -> Result<()>

Stores a float parameter at the given id.

Source

pub fn kind(&self, id: i32) -> Result<Option<ParamKind>>

Reports how a parameter is stored, or None when the identifier is unset.

A custom layer reads parameters by identifier, so this decides which getter applies.

Source

pub fn get_int(&self, id: i32, default: i32) -> Result<i32>

Reads an integer parameter, falling back to the default.

Source

pub fn get_float(&self, id: i32, default: f32) -> Result<f32>

Reads a float parameter, falling back to the default.

Source

pub fn set_array(&mut self, id: i32, value: &Mat) -> Result<()>

Stores an owned copy of a tensor parameter.

Source

pub fn set_bytes(&mut self, id: i32, value: &[u8]) -> Result<()>

Stores a byte string parameter.

Source

pub fn get_bytes(&self, id: i32) -> Result<Vec<u8>>

Copies a byte string parameter.

Source

pub fn as_raw(&self) -> ncnn_paramdict_t

Borrows the native dictionary handle.

Trait Implementations§

Source§

impl Drop for ParamDict

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§

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.