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 underlyingMNNScheduleConfig
structure.backend_config
: Specifies backend-specific configurations.__marker
: A marker to ensure the struct is!Send
by default.
§Methods
new() -> Self
: Creates a newScheduleConfig
with default settings.as_ptr_mut(&mut self) -> *mut MNNScheduleConfig
: Returns a mutable raw pointer to the underlyingMNNScheduleConfig
.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
impl ScheduleConfig
sourcepub fn as_ptr_mut(&mut self) -> *mut MNNScheduleConfig
pub fn as_ptr_mut(&mut self) -> *mut MNNScheduleConfig
Returns a mutable raw pointer to the underlying MNNScheduleConfig
.
sourcepub fn set_save_tensors(&mut self, save_tensors: &[&str]) -> Result<&mut Self>
pub fn set_save_tensors(&mut self, save_tensors: &[&str]) -> Result<&mut Self>
sourcepub fn set_type(&mut self, forward_type: ForwardType) -> &mut Self
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.
sourcepub fn with_type(self, forward_type: ForwardType) -> Self
pub fn with_type(self, forward_type: ForwardType) -> Self
Sets the type of backend to be used for computation.
sourcepub fn get_type(&self) -> ForwardType
pub fn get_type(&self) -> ForwardType
Gets the type of backend to be used for computation.
sourcepub fn set_num_threads(&mut self, num_threads: i32) -> &mut Self
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.
sourcepub fn with_num_threads(self, num_threads: i32) -> Self
pub fn with_num_threads(self, num_threads: i32) -> Self
Sets the number of threads to be used for computation.
sourcepub fn set_backup_type(&mut self, backup_type: ForwardType) -> &mut Self
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.
sourcepub fn with_backup_type(self, backup_type: ForwardType) -> Self
pub fn with_backup_type(self, backup_type: ForwardType) -> Self
Sets the backup type of backend to be used if the primary backend fails.
sourcepub fn get_backup_type(&self) -> ForwardType
pub fn get_backup_type(&self) -> ForwardType
Gets the backup type of backend to be used if the primary backend fails.
sourcepub fn set_backend_config(
&mut self,
backend_config: impl Into<Option<BackendConfig>>,
) -> &mut Self
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.
sourcepub fn with_backend_config(
self,
backend_config: impl Into<Option<BackendConfig>>,
) -> Self
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
impl Clone for ScheduleConfig
source§impl Debug for ScheduleConfig
impl Debug for ScheduleConfig
source§impl Default for ScheduleConfig
impl Default for ScheduleConfig
source§impl Drop for ScheduleConfig
impl Drop for ScheduleConfig
source§impl FromIterator<ScheduleConfig> for ScheduleConfigs
impl FromIterator<ScheduleConfig> for ScheduleConfigs
source§fn from_iter<T: IntoIterator<Item = ScheduleConfig>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = ScheduleConfig>>(iter: T) -> Self
impl Send for ScheduleConfig
Auto Trait Implementations§
impl Freeze for ScheduleConfig
impl RefUnwindSafe for ScheduleConfig
impl !Sync for ScheduleConfig
impl Unpin for ScheduleConfig
impl UnwindSafe for ScheduleConfig
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)