Skip to main content

InitOptionsUserDefined

Struct InitOptionsUserDefined 

Source
#[non_exhaustive]
pub struct InitOptionsUserDefined { pub environment: Option<Environment>, pub execution_providers: Vec<ExecutionProviderDispatch>, pub max_length: usize, pub intra_threads: Option<usize>, pub disable_cpu_fallback: bool, pub dimension_overrides: Vec<(String, i64)>, pub session_config: Vec<(String, String)>, pub auto_device: Option<AutoDevicePolicy>, }
Available on crate feature onnx only.
Expand description

Options for initializing a user-defined embedding model.

Model files are held by the UserDefinedEmbeddingModel struct

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§environment: Option<Environment>§execution_providers: Vec<ExecutionProviderDispatch>§max_length: usize§intra_threads: Option<usize>

Number of intra-op threads for ONNX Runtime. None (the default) uses every available CPU core via std::thread::available_parallelism. Set this to cap CPU usage (e.g. on laptops) at the cost of throughput.

§disable_cpu_fallback: bool

Refuse session creation when any graph node would fall back to the CPU execution provider. This is useful for accelerator conformance tests and for applications where silent partial placement is incorrect.

§dimension_overrides: Vec<(String, i64)>

Override named free dimensions before ORT optimizes and places the graph. Static-shape execution providers such as QNN can use this with one user-defined model session per admitted shape.

§session_config: Vec<(String, String)>

ONNX Runtime session configuration entries, applied with SessionBuilder::with_config_entry. Use this for settings that have no dedicated builder method, such as mlas.disable_kleidiai.

§auto_device: Option<AutoDevicePolicy>

Policy for ONNX Runtime’s automatic execution provider selection, applied with SessionBuilder::with_auto_device. None (the default) keeps ort’s default, AutoDevicePolicy::MaxEfficiency, which registers CoreML on macOS. Some(AutoDevicePolicy::PreferCPU) never registers an execution provider automatically. Execution providers passed through execution_providers take precedence over automatic selection.

Implementations§

Source§

impl InitOptionsUserDefined

Source

pub fn new() -> Self

Source

pub fn with_environment(self, environment: Environment) -> Self

Source

pub fn with_execution_providers( self, execution_providers: Vec<ExecutionProviderDispatch>, ) -> Self

Source

pub fn with_max_length(self, max_length: usize) -> Self

Source

pub fn with_intra_threads(self, intra_threads: usize) -> Self

Set the number of intra-op threads ONNX Runtime uses. By default (None) all available CPU cores are used. Capping this limits CPU usage at the cost of per-inference throughput.

Source

pub fn with_disable_cpu_fallback(self, disable: bool) -> Self

Source

pub fn with_dimension_override(self, name: impl Into<String>, size: i64) -> Self

Source

pub fn with_session_config( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Add an ONNX Runtime session configuration entry, applied with SessionBuilder::with_config_entry. Call it once per entry. Example: .with_session_config("mlas.disable_kleidiai", "1").

Source

pub fn with_auto_device(self, policy: AutoDevicePolicy) -> Self

Set the policy for ONNX Runtime’s automatic execution provider selection, applied with SessionBuilder::with_auto_device. Example: .with_auto_device(AutoDevicePolicy::PreferCPU) keeps every node on the CPU when no execution provider is registered explicitly.

Trait Implementations§

Source§

impl Clone for InitOptionsUserDefined

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for InitOptionsUserDefined

Source§

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

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

impl Default for InitOptionsUserDefined

Source§

fn default() -> Self

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

impl From<InitOptionsWithLength<EmbeddingModel>> for InitOptionsUserDefined

Convert InitOptions to InitOptionsUserDefined

This is useful for when the user wants to use the same options for both the default and user-defined models

Source§

fn from(options: TextInitOptions) -> Self

Converts to this type from the input type.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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 = !

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V