# ORTSession Class Reference

# ORTSession

Objective-C

    @interface ORTSession : NSObject

Swift

    class ORTSession : NSObject

An ORT session loads and runs a model.

- `-init`

  Unavailable

  #### Declaration

  Objective-C

      - (instancetype)init NS_UNAVAILABLE;

- `-initWithEnv:modelPath:sessionOptions:error:`

  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?) throws

  #### Parameters

  `env` | The ORT Environment instance.
  `path` | The path to the ONNX model.
  `sessionOptions` | Optional session configuration options.
  `error` | Optional error information set if an error occurs.

  #### Return Value

  The instance, or nil if an error occurs.

- `-runWithInputs:outputs:runOptions:error:`

  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?) throws

  #### Parameters

  `inputs` | Dictionary of input names to input ORT values.
  `outputs` | Dictionary of output names to output ORT values.
  `runOptions` | Optional run configuration options.
  `error` | Optional error information set if an error occurs.

  #### Return Value

  Whether the model was run successfully.

- `-runWithInputs:outputNames:runOptions:error:`

  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

  `inputs` | Dictionary of input names to input ORT values.
  `outputNames` | Set of output names.
  `runOptions` | Optional run configuration options.
  `error` | Optional 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.

- `-inputNamesWithError:`

  Gets the model’s input names.

  #### Declaration

  Objective-C

      - (nullable NSArray<NSString *> *)inputNamesWithError:
          (NSError *_Nullable *_Nullable)error;

  Swift

      func inputNames() throws -> [String]

  #### Parameters

  `error` | Optional error information set if an error occurs.

  #### Return Value

  An array of input names, or nil if an error occurs.

- `-overridableInitializerNamesWithError:`

  Gets the model’s overridable initializer names.

  #### Declaration

  Objective-C

      - (nullable NSArray<NSString *> *)overridableInitializerNamesWithError:
          (NSError *_Nullable *_Nullable)error;

  Swift

      func overridableInitializerNames() throws -> [String]

  #### Parameters

  `error` | Optional error information set if an error occurs.

  #### Return Value

  An array of overridable initializer names, or nil if an error occurs.

- `-outputNamesWithError:`

  Gets the model’s output names.

  #### Declaration

  Objective-C

      - (nullable NSArray<NSString *> *)outputNamesWithError:
          (NSError *_Nullable *_Nullable)error;

  Swift

      func outputNames() throws -> [String]

  #### Parameters

  `error` | Optional error information set if an error occurs.

  #### Return Value

  An array of output names, or nil if an error occurs.

© 2022 ONNX Runtime Authors. All rights reserved. (Last updated: 2022-10-22)

Generated by jazzy ♪♫ v0.14.3, a Realm project.