ORTSessionOptions

Objective-C

@interface ORTSessionOptions : NSObject

Swift

class ORTSessionOptions : NSObject

Options for configuring a session.

  • Unavailable

    Declaration

    Objective-C

    - (instancetype)init NS_UNAVAILABLE;
  • Creates session configuration options.

    Declaration

    Objective-C

    - (nullable instancetype)initWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    init() throws

    Parameters

    error

    Optional error information set if an error occurs.

    Return Value

    The instance, or nil if an error occurs.

  • Sets the number of threads used to parallelize the execution within nodes. A value of 0 means ORT will pick a default value.

    Declaration

    Objective-C

    - (BOOL)setIntraOpNumThreads:(int)intraOpNumThreads
                           error:(NSError *_Nullable *_Nullable)error;

    Swift

    func setIntraOpNumThreads(_ intraOpNumThreads: Int32) throws

    Parameters

    intraOpNumThreads

    The number of threads.

    error

    Optional error information set if an error occurs.

    Return Value

    Whether the option was set successfully.

  • Sets the graph optimization level.

    Declaration

    Objective-C

    - (BOOL)setGraphOptimizationLevel:
                (ORTGraphOptimizationLevel)graphOptimizationLevel
                                error:(NSError *_Nullable *_Nullable)error;

    Swift

    func setGraphOptimizationLevel(_ graphOptimizationLevel: ORTGraphOptimizationLevel) throws

    Parameters

    graphOptimizationLevel

    The graph optimization level.

    error

    Optional error information set if an error occurs.

    Return Value

    Whether the option was set successfully.

  • Sets the path to which the optimized model file will be saved.

    Declaration

    Objective-C

    - (BOOL)setOptimizedModelFilePath:(nonnull NSString *)optimizedModelFilePath
                                error:(NSError *_Nullable *_Nullable)error;

    Swift

    func setOptimizedModelFilePath(_ optimizedModelFilePath: String) throws

    Parameters

    optimizedModelFilePath

    The optimized model file path.

    error

    Optional error information set if an error occurs.

    Return Value

    Whether the option was set successfully.

  • Sets the session log ID.

    Declaration

    Objective-C

    - (BOOL)setLogID:(nonnull NSString *)logID
               error:(NSError *_Nullable *_Nullable)error;

    Swift

    func setLogID(_ logID: String) throws

    Parameters

    logID

    The log ID.

    error

    Optional error information set if an error occurs.

    Return Value

    Whether the option was set successfully.

  • Sets the session log severity level.

    Declaration

    Objective-C

    - (BOOL)setLogSeverityLevel:(ORTLoggingLevel)loggingLevel
                          error:(NSError *_Nullable *_Nullable)error;

    Swift

    func setLogSeverityLevel(_ loggingLevel: ORTLoggingLevel) throws

    Parameters

    loggingLevel

    The log severity level.

    error

    Optional error information set if an error occurs.

    Return Value

    Whether the option was set successfully.

  • Sets a session configuration key-value pair. Any value for a previously set key will be overwritten. The session configuration keys and values are documented here: https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h

    Declaration

    Objective-C

    - (BOOL)addConfigEntryWithKey:(nonnull NSString *)key
                            value:(nonnull NSString *)value
                            error:(NSError *_Nullable *_Nullable)error;

    Swift

    func addConfigEntry(withKey key: String, value: String) throws

    Parameters

    key

    The key.

    value

    The value.

    error

    Optional error information set if an error occurs.

    Return Value

    Whether the option was set successfully.

ORTSessionOptionsCoreMLEP

  • Enables the CoreML execution provider in the session configuration options. It is appended to the execution provider list which is ordered by decreasing priority.

    Declaration

    Objective-C

    - (BOOL)appendCoreMLExecutionProviderWithOptions:
                (nonnull ORTCoreMLExecutionProviderOptions *)options
                                               error:(NSError *_Nullable *_Nullable)
                                                         error;

    Swift

    func appendCoreMLExecutionProvider(with options: ORTCoreMLExecutionProviderOptions) throws

    Parameters

    options

    The CoreML execution provider configuration options.

    error

    Optional error information set if an error occurs.

    Return Value

    Whether the provider was enabled successfully.