# ORTValue Class Reference

# ORTValue

Objective-C

    @interface ORTValue : NSObject

Swift

    class ORTValue : NSObject

An ORT value encapsulates data used as an input or output to a model at runtime.

- `-init`

  Unavailable

  #### Declaration

  Objective-C

      - (instancetype)init NS_UNAVAILABLE;

- `-initWithTensorData:elementType:shape:error:`

  Creates a value that is a tensor. The tensor data is allocated by the caller.

  #### Declaration

  Objective-C

      - (nullable instancetype)
          initWithTensorData:(nonnull NSMutableData *)tensorData
                 elementType:(ORTTensorElementDataType)elementType
                       shape:(nonnull NSArray<NSNumber *> *)shape
                       error:(NSError *_Nullable *_Nullable)error;

  Swift

      init(tensorData: NSMutableData, elementType: ORTTensorElementDataType, shape: [NSNumber]) throws

  #### Parameters

  `tensorData` | The tensor data.
  `elementType` | The tensor element data type.
  `shape` | The tensor shape.
  `error` | Optional error information set if an error occurs.

  #### Return Value

  The instance, or nil if an error occurs.

- `-typeInfoWithError:`

  Gets the type information.

  #### Declaration

  Objective-C

      - (nullable ORTValueTypeInfo *)typeInfoWithError:
          (NSError *_Nullable *_Nullable)error;

  Swift

      func typeInfo() throws -> ORTValueTypeInfo

  #### Parameters

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

  #### Return Value

  The type information, or nil if an error occurs.

- `-tensorTypeAndShapeInfoWithError:`

  Gets the tensor type and shape information. This assumes that the value is a tensor.

  #### Declaration

  Objective-C

      - (nullable ORTTensorTypeAndShapeInfo *)tensorTypeAndShapeInfoWithError:
          (NSError *_Nullable *_Nullable)error;

  Swift

      func tensorTypeAndShapeInfo() throws -> ORTTensorTypeAndShapeInfo

  #### Parameters

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

  #### Return Value

  The tensor type and shape information, or nil if an error occurs.

- `-tensorDataWithError:`

  Gets the tensor data. This assumes that the value is a tensor.

  This returns the value’s underlying data directly, not a copy of it. The memory’s lifetime may be tied to this value, i.e., if it was allocated by ORT. On the other hand, the memory’s lifetime is independent of the value if the value was created with user-provided data.

  #### Declaration

  Objective-C

      - (nullable NSMutableData *)tensorDataWithError:
          (NSError *_Nullable *_Nullable)error;

  Swift

      func tensorData() throws -> NSMutableData

  #### Parameters

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

  #### Return Value

  The tensor data, 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.