mnn::schedule

Struct ScheduleConfig

source
pub struct ScheduleConfig { /* private fields */ }
Expand description

Configuration for scheduling the forward computation in MNN.

The ScheduleConfig struct is used to configure various parameters for scheduling the forward computation in the MNN framework. It allows setting the type of backend, the number of threads, the mode of computation, and other options.

§Example

use mnn::schedule::{ScheduleConfig, ForwardType};

let mut config = ScheduleConfig::new();
config.set_type(ForwardType::Auto);
config.set_num_threads(4);
config.set_mode(0);

§Fields

  • inner: A raw pointer to the underlying MNNScheduleConfig structure.
  • backend_config: Specifies backend-specific configurations.
  • __marker: A marker to ensure the struct is !Send by default.

§Methods

  • new() -> Self: Creates a new ScheduleConfig with default settings.
  • as_ptr_mut(&mut self) -> *mut MNNScheduleConfig: Returns a mutable raw pointer to the underlying MNNScheduleConfig.
  • set_save_tensors(&mut self, save_tensors: &[&str]) -> Result<()>: Sets the tensors to be saved during computation.
  • set_type(&mut self, forward_type: ForwardType): Sets the type of backend to be used for computation.
  • set_num_threads(&mut self, num_threads: i32): Sets the number of threads to be used for computation.
  • set_mode(&mut self, mode: i32): Sets the mode of computation.
  • set_backup_type(&mut self, backup_type: ForwardType): Sets the backup type of backend to be used if the primary backend fails.
  • set_backend_config(&mut self, backend_config: impl Into<Option<BackendConfig>>): Sets the backend-specific configuration.

§Safety

The ScheduleConfig struct contains raw pointers and interacts with the underlying C API of MNN. Users should be cautious when using this struct to avoid undefined behavior.

§Warning

Warning: The Drop implementation for ScheduleConfig ensures that the underlying MNNScheduleConfig is properly destroyed when the struct goes out of scope. Users should not manually free the inner pointer.

Implementations§

source§

impl ScheduleConfig

source

pub fn as_ptr_mut(&mut self) -> *mut MNNScheduleConfig

Returns a mutable raw pointer to the underlying MNNScheduleConfig.

source

pub fn new() -> Self

Creates a new ScheduleConfig with default settings.

source

pub fn set_save_tensors(&mut self, save_tensors: &[&str]) -> Result<&mut Self>

Sets the tensors to be saved during computation.

§Arguments
  • save_tensors: A slice of tensor names to be saved.
§Errors

Returns an error if any of the tensor names contain null bytes.

source

pub fn set_type(&mut self, forward_type: ForwardType) -> &mut Self

Sets the type of backend to be used for computation.

§Arguments
  • forward_type: The type of backend to be used.
source

pub fn with_type(self, forward_type: ForwardType) -> Self

Sets the type of backend to be used for computation.

source

pub fn get_type(&self) -> ForwardType

Gets the type of backend to be used for computation.

source

pub fn set_num_threads(&mut self, num_threads: i32) -> &mut Self

Sets the number of threads to be used for computation.

§Arguments
  • num_threads: The number of threads to be used.
source

pub fn with_num_threads(self, num_threads: i32) -> Self

Sets the number of threads to be used for computation.

source

pub fn set_mode(&mut self, mode: i32) -> &mut Self

Sets the mode of computation.

§Arguments
  • mode: The mode of computation.
source

pub fn with_mode(self, mode: i32) -> Self

Sets the mode of computation.

source

pub fn set_backup_type(&mut self, backup_type: ForwardType) -> &mut Self

Sets the backup type of backend to be used if the primary backend fails.

§Arguments
  • backup_type: The backup type of backend to be used.
source

pub fn with_backup_type(self, backup_type: ForwardType) -> Self

Sets the backup type of backend to be used if the primary backend fails.

source

pub fn get_backup_type(&self) -> ForwardType

Gets the backup type of backend to be used if the primary backend fails.

source

pub fn set_backend_config( &mut self, backend_config: impl Into<Option<BackendConfig>>, ) -> &mut Self

Sets the backend-specific configuration.

§Arguments
  • backend_config: specifies additional backend-specific configurations.
source

pub fn with_backend_config( self, backend_config: impl Into<Option<BackendConfig>>, ) -> Self

Sets the backend-specific configuration.

Trait Implementations§

source§

impl Clone for ScheduleConfig

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ScheduleConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ScheduleConfig

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Drop for ScheduleConfig

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl FromIterator<ScheduleConfig> for ScheduleConfigs

source§

fn from_iter<T: IntoIterator<Item = ScheduleConfig>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl Send for ScheduleConfig

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.