ORTSession
Objective-C
@interface ORTSession : NSObject
Swift
class ORTSession : NSObject
An ORT session loads and runs a model.
-
Unavailable
Declaration
Objective-C
- (instancetype)init NS_UNAVAILABLE; -
Creates a session.
Declaration
Objective-C
- (nullable instancetype)initWithEnv:(nonnull ORTEnv *)env modelPath:(nonnull NSString *)path sessionOptions: (nullable ORTSessionOptions *)sessionOptions error:(NSError *_Nullable *_Nullable)error;Swift
init(env: ORTEnv, modelPath path: String, sessionOptions: ORTSessionOptions?) throwsParameters
envThe ORT Environment instance.
pathThe path to the ONNX model.
sessionOptionsOptional session configuration options.
errorOptional error information set if an error occurs.
Return Value
The instance, or nil if an error occurs.
-
Runs the model. The inputs and outputs are pre-allocated.
Declaration
Objective-C
- (BOOL)runWithInputs:(nonnull NSDictionary<NSString *, ORTValue *> *)inputs outputs:(nonnull NSDictionary<NSString *, ORTValue *> *)outputs runOptions:(nullable ORTRunOptions *)runOptions error:(NSError *_Nullable *_Nullable)error;Swift
func run(withInputs inputs: [String : ORTValue], outputs: [String : ORTValue], runOptions: ORTRunOptions?) throwsParameters
inputsDictionary of input names to input ORT values.
outputsDictionary of output names to output ORT values.
runOptionsOptional run configuration options.
errorOptional error information set if an error occurs.
Return Value
Whether the model was run successfully.
-
Runs the model. The inputs are pre-allocated and the outputs are allocated by ORT.
Declaration
Objective-C
- (nullable NSDictionary<NSString *, ORTValue *> *) runWithInputs:(nonnull NSDictionary<NSString *, ORTValue *> *)inputs outputNames:(nonnull NSSet<NSString *> *)outputNames runOptions:(nullable ORTRunOptions *)runOptions error:(NSError *_Nullable *_Nullable)error;Swift
func run(withInputs inputs: [String : ORTValue], outputNames: Set<String>, runOptions: ORTRunOptions?) throws -> [String : ORTValue]Parameters
inputsDictionary of input names to input ORT values.
outputNamesSet of output names.
runOptionsOptional run configuration options.
errorOptional error information set if an error occurs.
Return Value
A dictionary of output names to output ORT values with the outputs requested in
outputNames, or nil if an error occurs. -
Gets the model’s input names.
Declaration
Objective-C
- (nullable NSArray<NSString *> *)inputNamesWithError: (NSError *_Nullable *_Nullable)error;Swift
func inputNames() throws -> [String]Parameters
errorOptional error information set if an error occurs.
Return Value
An array of input names, or nil if an error occurs.
-
Gets the model’s overridable initializer names.
Declaration
Objective-C
- (nullable NSArray<NSString *> *)overridableInitializerNamesWithError: (NSError *_Nullable *_Nullable)error;Swift
func overridableInitializerNames() throws -> [String]Parameters
errorOptional error information set if an error occurs.
Return Value
An array of overridable initializer names, or nil if an error occurs.
-
Gets the model’s output names.
Declaration
Objective-C
- (nullable NSArray<NSString *> *)outputNamesWithError: (NSError *_Nullable *_Nullable)error;Swift
func outputNames() throws -> [String]Parameters
errorOptional error information set if an error occurs.
Return Value
An array of output names, or nil if an error occurs.
View on GitHub
ORTSession Class Reference