### Install Metal Toolchain via Command Line Source: https://developer.apple.com/documentation/coreai/compiling-core-ai-models-ahead-of-time Install the Metal Toolchain from the command line, which is a prerequisite for using `coreai-build`. ```bash xcode-select --install ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/inferencefunction/asyncmutablevalue/init%28_%3A%29-x6se Initializes the AsyncMutableValue with a starting NDArray. This is a beta API. ```APIDOC ## init(_:) ### Description Initializes the state from an existing ndArray. ### Parameters #### Parameters - **ndArray** (consuming NDArray) - The starting ndArray value of this state. ### Discussion Beta Software This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software. Learn more about using Apple's beta software ``` -------------------------------- ### Get Minimum Byte Count for NDArray Storage Source: https://developer.apple.com/documentation/coreai/ndarraydescriptor/minimumbytecount This example demonstrates how to retrieve the minimum byte count for an NDArray descriptor and use it to allocate Metal buffer storage. It assumes the descriptor has static shapes. ```swift let metalDevice: any MTLDevice = ... let functionDescriptor = model.functionDescriptor(for: "main") guard case .ndArray(let ndArrayDescriptor) = functionDescriptor.inputDescriptor(of: "dynamic_shape_input") else { // Handle input not found or not ndArray } // Assuming that the descriptor is known to have static shapes. If it had dynamic shapes it'd be // required to first call `resolvingDynamicDimensions`. let byteCount = ndArrayDescriptor.minimumByteCount let metalBuffer = metalDevice.makeBuffer(length: byteCount)! // Later at inference time... manual allocations can be provided by making views from them. let view = NDArray.RawView( metalBuffer: metalBuffer, byteOffset: 0, shape: ndArrayDescriptor.shape, scalarType: ndArrayDescriptor.scalarType, strides: ndArrayDescriptor.preferredStrides ) var inputs = InferenceFunction.Inputs() inputs.insert(view, for: "myInput") var outputs = inferenceFunction.run(inputs: inputs) ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/coreai/inferencefunction/asyncmutableviews/init%28%29 Initializes an empty AsyncMutableViews object. This method is available for iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 (Beta). ```APIDOC ## init() ### Description Initializes an empty `AsyncMutableViews` object. ### Method Initializer ### Parameters None ### Response An empty `AsyncMutableViews` object. ### Beta Software This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software. ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue/init%28_%3A%29-61sg1 Creates a value containing the specified integer. This initializer is available on iOS, iPadOS, Mac Catalyst, tvOS, visionOS, and watchOS starting from version 27.0 (Beta). ```APIDOC ## init(_:) ### Description Creates a value containing the specified integer. ### Parameters #### Path Parameters - **value** (Int) - Description: The integer value to be stored in the CreatorDefinedValue. ### Availability - iOS 27.0+ Beta - iPadOS 27.0+ Beta - Mac Catalyst 27.0+ Beta - tvOS 27.0+ Beta - visionOS 27.0+ Beta - watchOS 27.0+ Beta ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/coreai/inferencefunction/inputs/init%28%29 Creates an empty set of inputs for InferenceFunction.Inputs. This method is available for iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 (Beta). ```APIDOC ## init() ### Description Creates an empty set of inputs. ### Method Initializer ### Endpoint N/A (SDK method) ### Parameters This method does not take any parameters. ### Request Example ```swift let inputs = InferenceFunction.Inputs() ``` ### Response #### Success Response An empty `InferenceFunction.Inputs` object. #### Response Example ```swift // Represents an empty set of inputs ``` ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue/init%28_%3A%29-2lzjt Creates a value containing the specified Boolean. This initializer is available for iOS, iPadOS, Mac Catalyst, tvOS, visionOS, and watchOS, starting from version 27.0, and is currently in Beta. ```APIDOC ## init(_:) ### Description Creates a value containing the specified Boolean. ### Method initializer ### Parameters #### Parameters - **value** (Bool) - Description not available in source. ``` -------------------------------- ### Obtain NDArrayDescriptor from InferenceFunctionDescriptor Source: https://developer.apple.com/documentation/coreai/ndarraydescriptor You can obtain an NDArrayDescriptor from an InferenceFunctionDescriptor by querying the descriptor of a specific input or output. This example shows how to get the descriptor for an input named 'x'. ```swift let valueDescriptor = functionDescriptor.inputDescriptor(of: "x")! guard case .ndArray(let ndArrayDescriptor) = valueDescriptor else { ... } ``` -------------------------------- ### AIModel init(resolvingBookmark:) Source: https://developer.apple.com/documentation/coreai/aimodel/init%28resolvingbookmark%3A%29 Creates an `AIModel` by resolving bookmark data that points to its specialized asset in a cache. This method is useful for reconstructing an AIModel instance from data previously obtained via `AIModel.bookmarkData`. ```APIDOC ## init(resolvingBookmark:) ### Description Creates an `AIModel` by resolving bookmark data pointing to its specialized asset in a cache. If the bookmark data can be resolved, the resulting `AIModel` pins and references the cache entry as the model that generated the bookmark data. If it cannot be resolved (e.g., the specialized asset entry is no longer present), `nil` is returned. ### Method `init?(resolvingBookmark bookmark: Data) throws` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **bookmark** (Data) - Required - Data previously obtained from `AIModel.bookmarkData`. ### Request Example None ### Response #### Success Response An `AIModel` instance if the bookmark data is successfully resolved, otherwise `nil`. #### Response Example ```json { "example": "AIModel instance or nil" } ``` ### Discussion Resolving bookmark data involves checking its validity, validating that the associated cache and cache entry it references exist, and returning an `AIModel` constructed with that specialized asset contained within that entry. If any of these steps fail, `nil` is returned. ``` -------------------------------- ### Get bookmarkData Source: https://developer.apple.com/documentation/coreai/aimodel/bookmarkdata Retrieve the serialized data for an AIModel's cached specialized asset entry. This data can be stored and later resolved to re-create the model. ```swift var bookmarkData: Data { get } ``` -------------------------------- ### Get Mutable Raw View of NDArray Source: https://developer.apple.com/documentation/coreai/ndarray/mutablerawview%28%29 Use this method to obtain a mutable view of the NDArray's raw byte storage. Available on iOS, iPadOS, macOS, tvOS, and visionOS starting from version 27.0. ```swift mutating func mutableRawView() -> NDArray.MutableRawView ``` -------------------------------- ### Create AIModel from URL Source: https://developer.apple.com/documentation/coreai/aimodel Initializes an AIModel from a .aimodel or .aimodelc file. Requires the file URL and specialization options. ```swift init(contentsOf: URL, options: SpecializationOptions) async throws ``` -------------------------------- ### Get Localized Error Description Source: https://developer.apple.com/documentation/coreai/asseterror/errordescription Access the errorDescription property to retrieve a localized string explaining the AssetError. Available on iOS, iPadOS, Mac Catalyst, tvOS, visionOS, and watchOS starting from version 27.0 (Beta). ```swift var errorDescription: String? { get } ``` -------------------------------- ### init(purgeConditions:) Source: https://developer.apple.com/documentation/coreai/aimodelcache/policy/init%28purgeconditions%3A%29 Creates a policy with the specified purge conditions. This is a Beta API. ```APIDOC ## init(purgeConditions:) ### Description Creates a policy with the specified purge conditions. ### Method initializer ### Parameters #### Parameters - **purgeConditions** (AIModelCache.Policy.PurgeConditions) - Required - The set of conditions under which the system can purge specialized assets. ``` -------------------------------- ### Get Raw View of NDArray Storage Source: https://developer.apple.com/documentation/coreai/ndarray/rawview%28%29 Call the rawView() method on an NDArray instance to obtain a read-only view of its raw byte storage. This method is available on iOS, iPadOS, macOS, tvOS, and visionOS starting from version 27.0. ```swift func rawView() -> NDArray.RawView ``` -------------------------------- ### AIModel init(contentsOf:options:) Source: https://developer.apple.com/documentation/coreai/aimodel/init%28contentsof%3Aoptions%3A%29 Creates an `AIModel` from a `.aimodel` or `.aimodelc` file. This initializer specializes the model if needed, caching the result for future calls. Specializing the model can take a significant amount of time depending on model size and the compute unit types it targets. This initializer always uses the `default` cache. ```APIDOC ## init(contentsOf:options:) ### Description Creates an `AIModel` from a `.aimodel` or `.aimodelc` file. This initializer specializes the model if needed, caching the result for future calls. ### Method `init` (initializer) ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters - **modelURL** (`URL`) - The URL of a `.aimodel` or `.aimodelc` file. - **options** (`SpecializationOptions`) - Options for the specialization process. Defaults to `.default`. ### Request Example ```swift init( contentsOf modelURL: URL, options: SpecializationOptions = .default ) async throws ``` ### Response #### Success Response An initialized `AIModel` instance. #### Response Example N/A (initializer) ### Discussion Specializing the model can take a significant amount of time depending on model size and the compute unit types it targets. This initializer always uses the `default` cache. ``` -------------------------------- ### Get the rank of an NDArray.MutableView Source: https://developer.apple.com/documentation/coreai/ndarray/mutableview/rank Access the rank property to get the number of dimensions of the tensor. This is available when the element type conforms to BitwiseCopyable. ```swift var rank: Int { get } ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/init%28%29 Creates metadata with no values set. This is a beta feature and is subject to change. ```APIDOC ## init() ### Description Creates metadata with no values set. ### Method initializer ### Parameters This initializer does not take any parameters. ### Response - Returns an instance of `AIModelAsset.Metadata` with default values. ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta tvOS 27.0+ Beta visionOS 27.0+ Beta watchOS 27.0+ Beta ``` -------------------------------- ### Constructing NDArray with Preferred Strides Source: https://developer.apple.com/documentation/coreai/ndarraydescriptor/preferredstrides This example demonstrates how to use preferredStrides to construct an NDArray. It checks if the preferred strides result in a contiguous layout and handles both cases accordingly. ```swift guard case .ndArray(let inputDescriptor) = inferenceFunctionDescriptor.inputDescriptor(of: "input") else { throw UnexpectedInferenceValueType() } let preferredStrides = inputDescriptor.preferredStrides var ndArray = NDArray(shape: [theShape], scalarType: .float32, strides: preferredStrides) var view = ndArray.mutableView(as: Float.self) if let contiguousElements = view.contiguousElements { // The preferred strides were a normal contiguous layout } else { // The preferred strides were non-contiguous view.withUnsafeMutablePointer { data, shape, strides in ... logic which respects whatever strides were preferred ... } } ``` -------------------------------- ### Get Mutable Typed View of NDArray Elements Source: https://developer.apple.com/documentation/coreai/ndarray/mutableview%28as%3A%29 Use this method to get a mutable view of the NDArray's elements, specifying the desired Swift type. Ensure the provided type matches the array's scalar type. ```swift mutating func mutableView(as type: T.Type = T.self) -> NDArray.MutableView where T : BitwiseCopyable ``` -------------------------------- ### AIModel Initialization Source: https://developer.apple.com/documentation/coreai/aimodel Initializes an AIModel from a .aimodel or .aimodelc file, or by resolving bookmark data for a cached specialized asset. ```APIDOC ## Initializers ### `init(contentsOf: URL, options: SpecializationOptions) async throws` Creates an `AIModel` from a `.aimodel` or `.aimodelc` file. ### `init?(resolvingBookmark: Data) throws` Create an `AIModel` by resolving bookmark data pointing to its specialized asset in a cache. ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/inferencefunction/asyncvalue/init%28_%3A%29-5qtut Initializes the `AsyncValue` holding the provided pixel buffer. ```APIDOC ## init(_:) ### Description Initialize the `AsyncValue` holding the provided pixel buffer. ### Method initializer ### Parameters #### Path Parameters - **pixelBuffer** (CVReadOnlyPixelBuffer) - Required - The pixel buffer to hold within the `AsyncValue`. ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue/init%28_%3A%29-5y6lm Creates a value containing the specified string. ```APIDOC ## init(_:) ### Description Creates a value containing the specified string. ### Parameters #### Parameters - **string** (String) - The string value to initialize the CreatorDefinedValue with. ``` -------------------------------- ### Get View Rank Source: https://developer.apple.com/documentation/coreai/ndarray/view Returns the rank (number of dimensions) of the tensor view. ```swift var rank: Int ``` -------------------------------- ### Creating and Converting NDArray Raw View Source: https://developer.apple.com/documentation/coreai/ndarray/rawview/init%28bytes%3Abyteoffset%3Ascalartype%3Ashape%3Astrides%3Ainterleavelayout%3A%29 Example of creating a raw view from a RawSpan and then converting it to a typed view. The conversion is checked at runtime to ensure the scalar type matches. ```swift let myBytes: RawSpan = ... let ndArrayRawView = NDArray.RawView(bytes: myBytes, scalarType: .float32, shape: [4, 5]) // This conversion is checked. If the type does not match the originally provided scalar type // it will trap at runtime. let floatView = ndArrayRawView.view(as: Float32.self) ``` -------------------------------- ### Initialize CreatorDefinedValue with a String Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue/init%28_%3A%29-5y6lm Creates an instance of `CreatorDefinedValue` by providing a string. This initializer is available on iOS, iPadOS, Mac Catalyst, tvOS, visionOS, and watchOS starting from version 27.0. ```swift init(_ string: String) ``` -------------------------------- ### Get View Shape Source: https://developer.apple.com/documentation/coreai/ndarray/view Returns the shape (dimensions) of the tensor view as a Span of integers. ```swift var shape: Span ``` -------------------------------- ### init(descriptor:) Source: https://developer.apple.com/documentation/coreai/inferencefunction/asyncmutablevalue/init%28descriptor%3A%29 Initializes a new state by creating a value matching the provided descriptor. The descriptor must not have a dynamic shape. ```APIDOC ## init(descriptor:) ### Description Initialize a new state by creating a value matching the provided descriptor. ### Parameters #### Parameters - **descriptor** (InferenceValue.Descriptor) - The descriptor of the inference value to be constructed and held by this state. The descriptor must not have a dynamic shape. ``` -------------------------------- ### Chaining Inference Functions with AsyncValue Source: https://developer.apple.com/documentation/coreai/inferencefunction/asyncvalue Demonstrates how to pipeline inference functions using AsyncValue. This example shows encoding text tokens with an embedding function and then decoding the embeddings with a decoder function, awaiting the final logits. ```swift // Pipeline encoding of a text embedding function followed by decoder var textTokens: NDArray = ... let embeddingOutputs = try textEmbeddingFunction.encode(inputs: ["tokens": .init(textTokens)]) let embeddings: InferenceFunction.AsyncValue = embeddingOutputs["embeddings"] let decoderOutputs = try decodingFunction.encode(inputs: ["embeddings": embeddings]) let logits = decoderOutputs["logits"]! // Await the compute of logits to be complete let logitsNDArray = try await logits.ndArray ``` -------------------------------- ### Initializers Source: https://developer.apple.com/documentation/coreai/inferencefunction/asyncmutableviews Initializes an empty AsyncMutableViews collection. ```APIDOC ## init() ### Description Initialize an empty `AsyncMutableViews`. ### Method `init()` ``` -------------------------------- ### Get Immutable Raw View Source: https://developer.apple.com/documentation/coreai/ndarray/mutablerawview Returns an immutable raw view over the same backing data. ```swift var rawView: NDArray.RawView ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/coreai/computestream/init%28%29 Initializes an empty compute stream. This is a convenience initializer for creating a new ComputeStream instance. ```APIDOC ## init() ### Description Initializes an empty compute stream. This is a convenience initializer for creating a new ComputeStream instance. ### Method convenience init() ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta tvOS 27.0+ Beta visionOS 27.0+ Beta ``` -------------------------------- ### Get Mutable Bytes Span Source: https://developer.apple.com/documentation/coreai/ndarray/mutablerawview Provides a mutable span over the backing bytes of the tensor. ```swift var mutableBytes: MutableRawSpan ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue/init%28_%3A%29-1q79a Creates a new instance of `CreatorDefinedValue` by initializing it with a dictionary. The dictionary's keys are strings, and its values are `AIModelAsset.Metadata.CreatorDefinedValue` objects. ```APIDOC ## init(_:) ### Description Creates a value containing the specified dictionary. ### Method `init(_:)` ### Parameters #### dictionary - **dictionary** ([String : AIModelAsset.Metadata.CreatorDefinedValue]) - The dictionary to initialize the value with. ### Remarks This is a beta API and is subject to change. ``` -------------------------------- ### Get the Number of Outputs Source: https://developer.apple.com/documentation/coreai/inferencefunctiondescriptor/outputcount Retrieve the number of outputs for an inference function. This is a read-only property. ```swift var outputCount: Int { get } ``` -------------------------------- ### Create CreatorDefinedValue with Dictionary Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue/init%28_%3A%29-1q79a Use this initializer to create a `CreatorDefinedValue` by providing a dictionary where keys are strings and values are `CreatorDefinedValue` instances. Available on iOS, iPadOS, Mac Catalyst, tvOS, visionOS, and watchOS starting from version 27.0 (Beta). ```swift init(_ dictionary: [String : AIModelAsset.Metadata.CreatorDefinedValue]) ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue/init%28_%3A%29-9xsmm Creates a value containing the specified array of AIModelAsset.Metadata.CreatorDefinedValue. ```APIDOC ## init(_:) ### Description Creates a value containing the specified array. ### Parameters #### Parameters * `array` - An array of `AIModelAsset.Metadata.CreatorDefinedValue` to initialize the value with. ### Returns A new `AIModelAsset.Metadata.CreatorDefinedValue` instance containing the provided array. ``` -------------------------------- ### Get Interleave Layout Source: https://developer.apple.com/documentation/coreai/ndarray/mutableview Returns information about interleaved dimensions, if any. Returns nil if the layout is not interleaved. ```swift var interleaveLayout: NDArray.InterleaveLayout? ``` -------------------------------- ### Get AIModelAsset Summary Source: https://developer.apple.com/documentation/coreai/aimodelasset/summary%28includingstatistics%3A%29 Call this method to retrieve a summary of the AIModelAsset. Set `includingStatistics` to `true` to include detailed model statistics, which can be slower for large models. If `false`, only version information and function signatures are returned. ```swift func summary(includingStatistics: Bool) throws -> AIModelAsset.Summary? ``` -------------------------------- ### Get View Strides Source: https://developer.apple.com/documentation/coreai/ndarray/view Returns the strides (memory step for each dimension) of the tensor view as a Span of integers. ```swift var strides: Span ``` -------------------------------- ### Creating an NDArray with Scalar Values Source: https://developer.apple.com/documentation/coreai/ndarray/init%28scalars%3Ashape%3A%29 This example demonstrates how to create an `Int32` NDArray with a shape of [2, 2] using a range of integers as scalar values. The scalars are copied into the NDArray in row-major order. ```swift var ndArray = NDArray(scalars: (0..<4) as Range, shape: [2, 2]) // The resulting NDArray has contents: // [[0, 1], [2, 3]] ``` -------------------------------- ### Get Operation Count Source: https://developer.apple.com/documentation/coreai/aimodelasset/summary/operationcount/count Retrieves the number of times a specific operation occurs in the model. This is a read-only property. ```swift var count: Int { get } ``` -------------------------------- ### init(commandQueue:) Source: https://developer.apple.com/documentation/coreai/computestream/init%28commandqueue%3A%29 Initializes a compute stream that will encode its work to the provided command queue. This allows for encoding inferences directly to your own Metal queue. ```APIDOC ## init(commandQueue:) ### Description Initializes a compute stream which will encode its work to the provided command queue. ### Method init ### Parameters #### Path Parameters * **commandQueue** (any MTLCommandQueue) - Required - The queue which inference will be encoded to when running `encode(inputs:states:outputViews:to:)`. ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/coreai/inferencefunction/mutableviews/init%28%29 Initializes an empty instance of InferenceFunction.MutableViews. This method is currently in Beta. ```APIDOC ## init() ### Description Initializes an empty instance. ### Method Initializer ### Parameters This method does not take any parameters. ### Response Initializes an empty instance. ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta tvOS 27.0+ Beta visionOS 27.0+ Beta ``` -------------------------------- ### Get All Function Names Source: https://developer.apple.com/documentation/coreai/aimodel Returns an array containing the names of all inference functions available within this AIModel. ```swift var functionNames: [String] ``` -------------------------------- ### Instance Properties Source: https://developer.apple.com/documentation/coreai/aimodel Provides access to the bookmark data for the AIModel's cached specialized asset entry. ```APIDOC ## Instance Properties ### `var bookmarkData: Data` Create a bookmark for this AIModel’s cached specialized asset entry as serialized data. ``` -------------------------------- ### Get Mutable Raw View Source: https://developer.apple.com/documentation/coreai/ndarray/mutableview Returns a type-erased mutable view over the same data. This allows for more generic memory manipulation. ```swift var mutableRawView: NDArray.MutableRawView ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue/init%28_%3A%29-40q72 Creates a value containing the specified double-precision number. ```APIDOC ## init(_:) ### Description Creates a value containing the specified double-precision number. ### Method initializer ### Parameters #### Parameters - **value** (Double) - The double-precision number to create the value from. ``` -------------------------------- ### Get Immutable View Source: https://developer.apple.com/documentation/coreai/ndarray/mutableview Returns an immutable view of the same tensor data. This is useful for read-only operations after modifications are complete. ```swift var view: NDArray.View ``` -------------------------------- ### Get NDArray Scalar Type Source: https://developer.apple.com/documentation/coreai/ndarray Retrieves the scalar type of the NDArray, indicating the type of data stored. This property is read-only. ```swift var scalarType: NDArray.ScalarType ``` -------------------------------- ### Get State Descriptor Source: https://developer.apple.com/documentation/coreai/inferencefunctiondescriptor/statedescriptor%28of%3A%29 Use stateDescriptor(of:) to retrieve the descriptor for a specific state by its name. Returns nil if the state does not exist. ```swift func stateDescriptor(of stateName: String) -> InferenceValue.Descriptor? ``` -------------------------------- ### init(ioSurface:byteOffset:scalarType:shape:strides:interleaveLayout:) Source: https://developer.apple.com/documentation/coreai/ndarray/mutablerawview/init%28iosurface%3Abyteoffset%3Ascalartype%3Ashape%3Astrides%3Ainterleavelayout%3A%29 Initializes a mutable raw view from an existing IOSurface, interpreted as the specified scalar type. This is a Beta API. ```APIDOC ## init(ioSurface:byteOffset:scalarType:shape:strides:interleaveLayout:) ### Description Initializes a mutable raw view from an existing IOSurface, interpreted as the specified scalar type. The pixel format of the IOSurface is ignored, and the provided `scalarType` is used. The `shape` argument is validated against the `height` and `width` of the IOSurface. ### Parameters #### Path Parameters * **ioSurface** (borrowing IOSurface) - Required - The IOSurface to be referenced by the resulting view. * **byteOffset** (Int) - Optional - Default: 0 - The offset into this IOSurface to be interpreted as the start of this view. * **scalarType** (NDArray.ScalarType) - Required - The type of scalars in the provided span. * **shape** ([Int]) - Required - The shape of the resulting view. * **strides** ([Int]) - Optional - Default: [] - The strides of the resulting view. If left empty, they will be computed as contiguous row-major. * **interleaveLayout** (NDArray.InterleaveLayout?) - Optional - Default: nil - Which dimension is interleaved and by what factor. See `NDArray.InterleaveLayout`. ### Notes - The `height` and `width` fields of the IOSurface must either be unspecified, or if present, the final dimension of `shape` must equal `width`, and the product of the remaining dimensions must equal `height`. - You are responsible for having locked the base address of the IOSurface before constructing the view. - The provided `scalarType` will be stored and checked later if you attempt to convert the raw view to a typed view. - The `shape` and `strides` must not produce offsets that go outside the IOSurface range. - This initializer is unsafe. You are responsible for ensuring no other code reads or writes the IOSurface while the resulting view is alive. ### Availability iOS 27.0+ Beta, iPadOS 27.0+ Beta, Mac Catalyst 27.0+ Beta, tvOS 27.0+ Beta, visionOS 27.0+ Beta ``` -------------------------------- ### Get NDArray Strides Source: https://developer.apple.com/documentation/coreai/ndarray Retrieves the strides of the NDArray, indicating the distance in elements between consecutive values along each dimension. This property is read-only. ```swift var strides: [Int] ``` -------------------------------- ### AIModel Initializer Source: https://developer.apple.com/documentation/coreai/aimodel/init%28resolvingbookmark%3A%29 Initializes an AIModel by resolving bookmark data. Returns nil if the bookmark data is invalid or the associated asset is no longer present. ```swift init?(resolvingBookmark bookmark: Data) throws ``` -------------------------------- ### AIModelAsset init(contentsOf:) Source: https://developer.apple.com/documentation/coreai/aimodelasset/init%28contentsof%3A%29 Creates a model asset from the contents of the specified URL. This is a beta feature available from iOS 27.0 onwards. ```APIDOC ## init(contentsOf:) ### Description Creates a model asset from the contents of the specified URL. ### Signature ```swift init(contentsOf url: URL) throws ``` ### Parameters #### url - **url** (URL) - Required - The asset URL. ### See Also - `static func isValid(at: URL) -> Bool` - Returns a Boolean value that indicates whether the URL contains a valid model asset. ``` -------------------------------- ### Get Immutable Raw View Source: https://developer.apple.com/documentation/coreai/ndarray/mutablerawview/rawview Accesses the immutable raw view of the NDArray.MutableRawView's backing data. This property is marked as beta. ```swift @export(implementation) var rawView: NDArray.RawView { get } ``` -------------------------------- ### Create AIModel from Bookmark Data Source: https://developer.apple.com/documentation/coreai/aimodel Creates an AIModel by resolving bookmark data that points to its specialized asset in a cache. This is useful for retrieving previously specialized models. ```swift init?(resolvingBookmark: Data) throws ``` -------------------------------- ### Get the number of inputs for an inference function Source: https://developer.apple.com/documentation/coreai/inferencefunctiondescriptor/inputcount Access the inputCount property to determine how many inputs a function expects. This property is read-only. ```swift var inputCount: Int { get } ``` -------------------------------- ### Initialize Empty Compute Stream Source: https://developer.apple.com/documentation/coreai/computestream/init%28%29 Use this convenience initializer to create an empty compute stream. This API is currently in beta. ```swift convenience init() ``` -------------------------------- ### scalarType Source: https://developer.apple.com/documentation/coreai/ndarray/scalartype-swift.property The scalar type of the array. Available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 (Beta). ```APIDOC ## scalarType ### Description The scalar type of the array. ### Property `var scalarType: NDArray.ScalarType { get }` ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta tvOS 27.0+ Beta visionOS 27.0+ Beta ``` -------------------------------- ### count Source: https://developer.apple.com/documentation/coreai/inferencefunction/outputs/count The number of outputs in this collection. Available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 (Beta). ```APIDOC ## count ### Description The number of outputs in this collection. ### Property `var count: Int { get }` ### Availability - iOS 27.0+ (Beta) - iPadOS 27.0+ (Beta) - Mac Catalyst 27.0+ (Beta) - tvOS 27.0+ (Beta) - visionOS 27.0+ (Beta) ``` -------------------------------- ### Get NDArray Shape Source: https://developer.apple.com/documentation/coreai/ndarray/shape Retrieves the shape of an NDArray, which is an array of integers representing the length of each dimension. Available on iOS 27.0+ Beta and later. ```swift var shape: [Int] { get } ``` -------------------------------- ### Get Mutable View of InferenceValue Source: https://developer.apple.com/documentation/coreai/inferencevalue/mutableviewrepresentable/mutableview%28%29 Use this method to obtain a mutable view of an InferenceValue. This is a Beta feature available from iOS 27.0 onwards. ```swift mutating func mutableView() -> InferenceValue.MutableView ``` -------------------------------- ### Initialize SpecializationOptions with Preferred Compute Unit Kind Source: https://developer.apple.com/documentation/coreai/specializationoptions/init%28preferredcomputeunitkind%3A%29 Use this initializer to create SpecializationOptions and specify a preferred compute unit kind for model specialization. The model will prioritize this kind but may fall back to others. ```swift init(preferredComputeUnitKind: ComputeUnitKind) ``` -------------------------------- ### NDArray.ScalarType.float64 Source: https://developer.apple.com/documentation/coreai/ndarray/scalartype-swift.enum/float64 Represents a 64-bit floating-point number within the NDArray.ScalarType enum. This case is available for various Apple platforms starting from iOS 27.0. ```APIDOC ## NDArray.ScalarType.float64 A 64-bit floating-point type. iOS 27.0+Beta ipadOS 27.0+Beta macCatalyst 27.0+Beta tvOS 27.0+Beta visionOS 27.0+Beta ### Case ```swift case float64 ``` ### See Also - `case float16`: A 16-bit floating-point type. - `case float32`: A 32-bit floating-point type. - `case bfloat16`: A 16-bit brain floating-point type. ``` -------------------------------- ### Initialize AIModelAsset.Metadata Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/init%28%29 Use this initializer to create an instance of AIModelAsset.Metadata with all properties unset. This is the default initializer and requires no arguments. ```swift init() ``` -------------------------------- ### NDArray.ScalarType.int16 Source: https://developer.apple.com/documentation/coreai/ndarray/scalartype-swift.enum/int16 Represents a 16-bit signed integer. Available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 (Beta). ```APIDOC ## NDArray.ScalarType.int16 A 16-bit signed integer. ### Case ```swift case int16 ``` ### Availability - iOS 27.0+ Beta - iPadOS 27.0+ Beta - Mac Catalyst 27.0+ Beta - tvOS 27.0+ Beta - visionOS 27.0+ Beta ``` -------------------------------- ### SpecializationOptions Initializer Source: https://developer.apple.com/documentation/coreai/specializationoptions/init%28preferredcomputeunitkind%3A%29 Creates SpecializationOptions with a preferred compute unit kind. The specialization process maximizes the use of the specified compute unit kind, falling back to other allowed compute units for incompatible operations. ```APIDOC ## init(preferredComputeUnitKind:) ### Description Creates options with a preferred compute unit kind. ### Method Initializer ### Parameters #### `preferredComputeUnitKind` - **ComputeUnitKind** - Required - The compute unit kind the specialized model should prefer. ### Discussion The specialization process maximizes use of the specified compute unit kind, falling back to other allowed compute units for incompatible operations. ``` -------------------------------- ### InferenceValue.Kind.ndArray Source: https://developer.apple.com/documentation/coreai/inferencevalue/kind-swift.enum/ndarray Represents a multidimensional array value. Available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 (Beta). ```APIDOC ## InferenceValue.Kind.ndArray A multidimensional array value. **Platforms:** iOS 27.0+ (Beta), iPadOS 27.0+ (Beta), Mac Catalyst 27.0+ (Beta), tvOS 27.0+ (Beta), visionOS 27.0+ (Beta) ### Case ```swift case ndArray ``` ### See Also #### Defining value kinds * `case image` - A pixel buffer image value. ``` -------------------------------- ### AIModelAsset Initialization Source: https://developer.apple.com/documentation/coreai/aimodelasset Initializes an AIModelAsset from the contents of a specified URL. This allows you to load a model asset for inspection. ```APIDOC ## init(contentsOf: URL) throws ### Description Creates a model asset from the contents of the specified URL. ### Parameters #### Path Parameters - **contentsOf** (URL) - Required - The URL of the `.aimodel` bundle on disk. ``` -------------------------------- ### stateDescriptor(of:) Source: https://developer.apple.com/documentation/coreai/inferencefunctiondescriptor/statedescriptor%28of%3A%29 Returns the descriptor for the specified state. This method is available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0. ```APIDOC ## stateDescriptor(of:) ### Description Returns the descriptor for the specified state. ### Method Instance Method ### Signature ```swift func stateDescriptor(of stateName: String) -> InferenceValue.Descriptor? ``` ### Parameters #### Path Parameters - **stateName** (String) - Required - The name of the state. ### Return Value The descriptor for the state, or `nil` if the function doesn’t have a state with the specified name. ### See Also - `var stateNames: [String]` - The names of the function’s states. ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/inferencefunction/asyncvalue/init%28_%3A%29-90hbj Initializes an async value from an existing mutable async value. The resulting value will reference the same underlying value within the mutable value and carry the same event to signal when the value is ready. ```APIDOC ## init(_:) ### Description Initializes an async value from an existing mutable async value. The resulting value will reference the same underlying value within the mutable value and carry the same event to signal when the value is ready. ### Parameters #### Parameters - **mutableValue** (InferenceFunction.AsyncMutableValue) - The mutable value that this value will be initialized from. The resulting value will reference the same underlying value within the mutable value and carry the same event to signal when the value is ready. ``` -------------------------------- ### name Source: https://developer.apple.com/documentation/coreai/aimodelasset/valuedescriptor/name The value’s name. Available on iOS, iPadOS, Mac Catalyst, tvOS, visionOS, and watchOS starting from version 27.0 (Beta). ```APIDOC ## name ### Description The value’s name. ### Property `var name: String { get }` ### Availability - iOS 27.0+ Beta - iPadOS 27.0+ Beta - Mac Catalyst 27.0+ Beta - tvOS 27.0+ Beta - visionOS 27.0+ Beta - watchOS 27.0+ Beta ``` -------------------------------- ### ComputeStream Initializers Source: https://developer.apple.com/documentation/coreai/computestream Initializes a ComputeStream. You can either create an empty stream or one that encodes work to a specific command queue. ```APIDOC ## Initializers ### `convenience init()` Initialize an empty compute stream. ### `init(commandQueue: any MTLCommandQueue)` Initialize a compute stream which will encode its work to the provided command queue. ``` -------------------------------- ### bookmarkData Source: https://developer.apple.com/documentation/coreai/aimodel/bookmarkdata Creates a bookmark for an AIModel's cached specialized asset entry as serialized data. This data can be stored and later used to re-create the model. ```APIDOC ## bookmarkData ### Description Creates a bookmark for this AIModel’s cached specialized asset entry as serialized data. The returned data can be stored and later resolved to re-create a model using `init?(resolvingBookmark:)`. It contains information about the cache and entry backing the model. ### Instance Property `var bookmarkData: Data { get }` ### Discussion Bookmark data is just data; it does not pin entries in the cache. Only an `AIModel` instance will pin its associated entry in the cache while it is held. ``` -------------------------------- ### description Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue/description A textual representation of the value. Available on iOS, iPadOS, Mac Catalyst, tvOS, visionOS, and watchOS starting from version 27.0 (Beta). ```APIDOC ## description ### Description A textual representation of the value. ### Property `var description: String { get }` ### Availability - iOS 27.0+ (Beta) - iPadOS 27.0+ (Beta) - Mac Catalyst 27.0+ (Beta) - tvOS 27.0+ (Beta) - visionOS 27.0+ (Beta) - watchOS 27.0+ (Beta) ``` -------------------------------- ### loadFunction(named:) Source: https://developer.apple.com/documentation/coreai/aimodel/loadfunction%28named%3A%29 Loads an inference function by its name. This method is part of the `AIModel` class and is available in beta versions starting from iOS 27.0. ```APIDOC ## loadFunction(named:) ### Description Loads an inference function from the AI model using its designated name. This is a beta feature available on multiple Apple platforms. ### Method Instance Method ### Signature ```swift func loadFunction(named functionName: String) throws -> InferenceFunction? ``` ### Parameters #### Path Parameters - **functionName** (String) - Required - The name of the inference function to load. ### Returns - **InferenceFunction?** - An optional `InferenceFunction` object if the function is found and loaded successfully, otherwise nil. This method can throw an error. ### Beta Software This documentation pertains to beta software and is subject to change. Use with caution and test thoroughly. ``` -------------------------------- ### Initialize AIModelCache Policy Source: https://developer.apple.com/documentation/coreai/aimodelcache/policy/init%28purgeconditions%3A%29 Use this initializer to create a policy object for AIModelCache, defining the criteria for when cached assets can be removed. ```swift init(purgeConditions: AIModelCache.Policy.PurgeConditions) ``` -------------------------------- ### Get Output Descriptor by Name Source: https://developer.apple.com/documentation/coreai/inferencefunctiondescriptor/outputdescriptor%28of%3A%29 Use this method to retrieve the descriptor for a specific output of an inference function. Returns `nil` if the output name is not found. ```swift func outputDescriptor(of outputName: String) -> InferenceValue.Descriptor? ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/coreai/inferencefunction/asyncmutablevalue/init%28_%3A%29-4aqgq Initializes the AsyncMutableValue with a given pixel buffer. This method is useful for setting the initial state of the mutable value from existing image data. ```APIDOC ## init(_:) ### Description Initialize the state from an existing pixel buffer. ### Parameters #### Parameters - **pixelBuffer** (CVMutablePixelBuffer) - Required - The starting pixel buffer value of this state. ``` -------------------------------- ### Get Input Descriptor by Name Source: https://developer.apple.com/documentation/coreai/inferencefunctiondescriptor/inputdescriptor%28of%3A%29 Use this method to retrieve the descriptor for a specific input of an inference function. Returns `nil` if the input name is not found. ```swift func inputDescriptor(of inputName: String) -> InferenceValue.Descriptor? ``` -------------------------------- ### AIModelCache Initializers Source: https://developer.apple.com/documentation/coreai/aimodelcache Initializes an AIModelCache. You can create a cache that shares specialized assets across an app group. ```APIDOC ## init?(appGroup: String) Creates a cache that shares specialized assets across an app group. ``` -------------------------------- ### Create an empty Inputs collection Source: https://developer.apple.com/documentation/coreai/inferencefunction/inputs Use the `init()` initializer to create an empty set of inputs before adding values. ```swift struct Inputs init() ``` -------------------------------- ### Inspect Image Properties Source: https://developer.apple.com/documentation/coreai/imagedescriptor Access properties of an ImageDescriptor to get details about the image. Use these properties to determine the pixel format, width, and height of an image. ```swift let pixelFormatType: OSType ``` ```swift let width: Int ``` ```swift let height: Int ``` -------------------------------- ### Accessing the Model Asset URL Source: https://developer.apple.com/documentation/coreai/aimodelasset/url Use this property to get the file URL of the model asset bundle. Available on iOS 27.0+ Beta and later. ```swift let url: URL ``` -------------------------------- ### Load AIModelAsset from URL Source: https://developer.apple.com/documentation/coreai/aimodelasset Creates a model asset from the contents of a specified URL. Use this to inspect model structure and metadata without performing expensive specialization. ```swift let asset = try AIModelAsset(contentsOf: modelURL) guard let summary = try asset.summary(includingStatistics: true) else { return } ``` -------------------------------- ### AIModelAsset.Summary Source: https://developer.apple.com/documentation/coreai/aimodelasset/summary Provides a summary of a model's structure and statistics, including compute types, storage types, operation distribution, and functions. ```APIDOC ## AIModelAsset.Summary A summary of a model’s structure and statistics. ### Overview Obtain a summary by calling `summary(includingStatistics:)`. The summary describes the model’s functions, storage types, compute types, and operation distribution. ### Topics #### Inspecting precision information `var computeTypes: [String]` The unique compute type names the model uses. `var storageTypes: [AIModelAsset.Summary.StorageType]` The unique scalar storage types and their element counts. #### Reviewing operation distribution `var operationDistribution: [AIModelAsset.Summary.OperationCount]` The distribution of operations in the model, each with a count. #### Inspecting functions `var functions: [AIModelAsset.FunctionDescriptor]` The functions in the model’s program. ### Supporting types `struct OperationCount` A model operation and the number of times it occurs. `struct StorageType` A scalar storage type and the number of elements that use it. ``` -------------------------------- ### NDArray.ScalarType.float16 Case Source: https://developer.apple.com/documentation/coreai/ndarray/scalartype-swift.enum/float16 Represents a 16-bit floating-point type. Available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 (Beta). ```swift case float16 ``` -------------------------------- ### init(kind:debugMessage:) Source: https://developer.apple.com/documentation/coreai/asseterror/init%28kind%3Adebugmessage%3A%29 Creates an asset error with a specified kind and an optional debug message. ```APIDOC ## init(kind:debugMessage:) ### Description Creates an asset error. ### Parameters `kind` (AssetError.Kind) - Required - The kind of error. `debugMessage` (String?) - Optional - An optional message with additional debugging context. ``` -------------------------------- ### Initializer for String Source: https://developer.apple.com/documentation/coreai/aimodelasset/metadata-swift.struct/creatordefinedvalue Creates a CreatorDefinedValue from a string. ```swift init(String) ``` -------------------------------- ### InferenceValue.Descriptor.ndArray(_:) Source: https://developer.apple.com/documentation/coreai/inferencevalue/descriptor/ndarray%28_%3A%29 Defines an NDArray descriptor for an InferenceValue. This is a beta feature available on iOS, iPadOS, macOS Catalyst, tvOS, and visionOS starting from version 27.0. ```APIDOC ## InferenceValue.Descriptor.ndArray(_:) ### Description Defines an NDArray descriptor for an InferenceValue. This is a beta feature available on iOS, iPadOS, macOS Catalyst, tvOS, and visionOS starting from version 27.0. ### Method Signature ```swift case ndArray(NDArrayDescriptor) ``` ### Parameters * **NDArrayDescriptor**: The descriptor for the NDArray. ### See Also * `case image(ImageDescriptor)` ``` -------------------------------- ### Creating and Viewing a Mutable Raw Array Source: https://developer.apple.com/documentation/coreai/ndarray/mutablerawview/init%28mutablebytes%3Abyteoffset%3Ascalartype%3Ashape%3Astrides%3Ainterleavelayout%3A%29 Demonstrates creating a mutable raw view from a MutableRawSpan and then converting it to a typed view. The conversion is checked at runtime to ensure the scalar type matches. ```swift let myBytes: MutableRawSpan = ... let ndArrayMutableRawView = NDArray.MutableRawView(bytes: myBytes, scalarType: .float32, shape: [4, 5]) // This conversion is checked. If the type does not match the originally provided scalar type // it will trap at runtime. let floatView = ndArrayMutableRawView.view(as: Float32.self) ``` -------------------------------- ### AIModelCache Instance Methods Source: https://developer.apple.com/documentation/coreai/aimodelcache Provides methods to manage cache entries, including deleting all entries, entries for a specific model, or a specific model and specialization options combination. It also allows retrieving a specialized model from the cache. ```APIDOC ## func deleteAll() throws Deletes all entries in the cache for the current build version. ``` ```APIDOC ## func deleteEntries(for: URL) throws Deletes all cache entries for a specific model, regardless of specialization options. ``` ```APIDOC ## func deleteEntry(for: URL, options: SpecializationOptions) throws Deletes the cache entry for a specific model and specialization options combination. ``` ```APIDOC ## func model(for: URL, options: SpecializationOptions) throws -> AIModel? Returns a previously specialized model from the cache, if available. ``` -------------------------------- ### ComputeUnitKind.cpu Case Source: https://developer.apple.com/documentation/coreai/computeunitkind/cpu Represents the central processing unit. Available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 Beta. ```swift case cpu ``` -------------------------------- ### InferenceFunction.MutableViews Initializers Source: https://developer.apple.com/documentation/coreai/inferencefunction/mutableviews Provides documentation for the initializers available for the MutableViews structure. ```APIDOC ## init() ### Description Initialize an empty instance of MutableViews. ### Method init() ### Parameters None ### Response An empty MutableViews instance. ``` -------------------------------- ### operationName Source: https://developer.apple.com/documentation/coreai/aimodelasset/summary/operationcount/operationname The name of the operation. This property is available for iOS, iPadOS, Mac Catalyst, tvOS, visionOS, and watchOS, starting from version 27.0, and is currently in Beta. ```APIDOC ## operationName ### Description The name of the operation. ### Property `var operationName: String { get }` ### Availability - iOS: 27.0+ (Beta) - iPadOS: 27.0+ (Beta) - Mac Catalyst: 27.0+ (Beta) - tvOS: 27.0+ (Beta) - visionOS: 27.0+ (Beta) - watchOS: 27.0+ (Beta) ### See Also - `count`: The number of times this operation occurs in the model. ``` -------------------------------- ### ImageDescriptor Height Property Source: https://developer.apple.com/documentation/coreai/imagedescriptor/height Declare an instance property 'height' of type Int to get the height of the image in pixels. A value of -1 indicates a dynamic shape. ```swift let height: Int ``` -------------------------------- ### Load Model from Bookmark Source: https://developer.apple.com/documentation/coreai/managing-model-specialization-and-caching On a subsequent launch, resolve a saved bookmark to load the model directly from the cache. Handles cases where the model cannot be found or was invalidated. ```swift if let bookmarkData = UserDefaults.standard.data(forKey: "llm.bookmark") { do { if let model = try AIModel(resolvingBookmark: bookmarkData) { // Use the model. return model } // The model can't be found or was invalidated by an OS update. } catch { // The bookmark data is invalid. } } // Download and specialize the model again. ``` -------------------------------- ### Get Inference Function Descriptor Source: https://developer.apple.com/documentation/coreai/aimodel Retrieves a descriptor for a specified inference function within the AIModel. This descriptor provides information about the function's inputs and outputs. ```swift func functionDescriptor(for: String) -> InferenceFunctionDescriptor? ``` -------------------------------- ### Initialize ComputeStream with Command Queue Source: https://developer.apple.com/documentation/coreai/computestream/init%28commandqueue%3A%29 Initializes a compute stream to encode its work to the provided command queue. Use this to encode inferences to your own Metal queue. ```swift init(commandQueue: any MTLCommandQueue) ``` -------------------------------- ### Default Specialization Options Source: https://developer.apple.com/documentation/coreai/specializationoptions Use this preset to allow the model to utilize all available compute units for inference. ```swift `static let `default`: SpecializationOptions` ``` -------------------------------- ### view() Source: https://developer.apple.com/documentation/coreai/inferencevalue/viewrepresentable/view%28%29 Returns an `InferenceValue.View` representation of the current `InferenceValue`. This method is part of the `InferenceValue.ViewRepresentable` protocol and is available on beta versions of Apple operating systems starting from 27.0. ```APIDOC ## view() ### Description Returns an `InferenceValue.View` representation of the current `InferenceValue`. This method is part of the `InferenceValue.ViewRepresentable` protocol and is available on beta versions of Apple operating systems starting from 27.0. ### Method Instance Method ### Returns `InferenceValue.View` ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta tvOS 27.0+ Beta visionOS 27.0+ Beta ### Beta Software This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software. ```