compileModel
TypeScriptstatic compileModelAt(modelURL: string): Promise<string>Swift declarationclass func compileModel(at modelURL: URL) async throws -> URLclass · iOS 11.0+ · SDK 27.1
class MLModelstatic compileModelAt(modelURL: string): Promise<string>Swift declarationclass func compileModel(at modelURL: URL) async throws -> URLstatic compileModelAt10374(modelURL: string): stringSwift declarationclass func compileModel(at modelURL: URL) throws -> URLstatic loadConfigurationCompletionHandler(asset: MLModelAsset, configuration: MLModelConfiguration, handler: ((arg0: (MLModel) | null, arg1: (NativeError) | null) => void)): voidSwift declarationclass func load(asset: MLModelAsset, configuration: MLModelConfiguration) async throws -> MLModelstatic initContentsOfConfiguration(url: string, configuration: MLModelConfiguration): MLModelSwift declarationconvenience init(contentsOf url: URL, configuration: MLModelConfiguration) throwsstatic initContentsOf(url: string): MLModelSwift declarationconvenience init(contentsOf url: URL) throwsparameterValue(key: MLParameterKey): unknownSwift declarationfunc parameterValue(for key: MLParameterKey) throws -> AnypredictionFrom(input: SDKHandle): SDKHandleSwift declarationfunc prediction(from input: any MLFeatureProvider) throws -> any MLFeatureProviderpredictionFromOptions(input: SDKHandle, options: MLPredictionOptions): SDKHandleSwift declarationfunc prediction(from input: any MLFeatureProvider, options: MLPredictionOptions) throws -> any MLFeatureProviderpredictionFromUsing(inputFeatures: SDKHandle, state: MLState): SDKHandleSwift declarationfunc prediction(from inputFeatures: any MLFeatureProvider, using state: MLState) throws -> any MLFeatureProviderpredictionFromUsingOptions(inputFeatures: SDKHandle, state: MLState, options: MLPredictionOptions): SDKHandleSwift declarationfunc prediction(from inputFeatures: any MLFeatureProvider, using state: MLState, options: MLPredictionOptions) throws -> any MLFeatureProviderpredictionsFromBatch(inputBatch: SDKHandle): SDKHandleSwift declarationfunc predictions(fromBatch inputBatch: any MLBatchProvider) throws -> any MLBatchProviderpredictionsFromOptions(inputBatch: SDKHandle, options: MLPredictionOptions): SDKHandleSwift declarationfunc predictions(from inputBatch: any MLBatchProvider, options: MLPredictionOptions) throws -> any MLBatchProviderget configuration(): MLModelConfigurationSwift declarationvar configuration: MLModelConfiguration { get }get modelDescription(): MLModelDescriptionSwift declarationvar modelDescription: MLModelDescription { get }predictionFromUsingOptions91549(input: SDKHandle, state: MLState, options?: MLPredictionOptions): Promise<SDKHandle>Swift declarationfunc prediction(from input: any MLFeatureProvider, using state: MLState, options: MLPredictionOptions = MLPredictionOptions()) async throws -> any MLFeatureProviderRun a stateful prediction on a model asynchronously. ```swift let state = model.newState() let prediction = try await model.prediction(from: inputFeatures, using: state) ``` - Parameters: - input: The input features to make a prediction from. - state: The state. - options: Optional prediction options to modify how the prediction is run - Returns: The output from the prediction.
predictionFromUsing53525(inputs: Record<string, MLTensor>, state: MLState): Promise<Record<string, MLTensor>>Swift declarationfunc prediction(from inputs: [String : MLTensor], using state: MLState) async throws -> [String : MLTensor]Run a stateful prediction on a model. This method requires all inputs and outputs to be multidimensional arrays. If your model doesn't satisfy this requirement, materialize the tensor inputs to `MLShapedArray` values to create feature values for each, for example: ```swift let shapedArray = await tensor.shapedArray(of: Float.self) let inputFeatures = try MLDictionaryFeatureProvider(dictionary: [ "x": MLFeatureValue(shapedArray: shapedArray), // Other non-multidimensional array inputs ]) let state = model.newState() let prediction = try await model.prediction(from: inputFeatures, using: state) ``` - Parameters: - inputs: The named input, or inputs, to make a prediction from. - state: The state. - Returns: The output, or outputs, from the prediction.
predictionFromOptions37517(input: SDKHandle, options?: MLPredictionOptions): Promise<SDKHandle>Swift declarationfunc prediction(from input: any MLFeatureProvider, options: MLPredictionOptions = MLPredictionOptions()) async throws -> any MLFeatureProviderRun a prediction on a model asynchronously. - Parameter input: The input features to make a prediction from. - Parameter options: Optional prediction options to modify how the prediction is run - Returns: The output from the prediction.
predictionFrom13483(inputs: Record<string, MLTensor>): Promise<Record<string, MLTensor>>Swift declarationfunc prediction(from inputs: [String : MLTensor]) async throws -> [String : MLTensor]Run a prediction on a model. This method requires all inputs and outputs to be multidimensional arrays. If your model doesn't satisfy this requirement, materialize the tensor inputs to `MLShapedArray` values to create feature values for each, for example: ```swift let shapedArray = await tensor.shapedArray(of: Float.self) let inputFeatures = try MLDictionaryFeatureProvider(dictionary: [ "x": MLFeatureValue(shapedArray: shapedArray), // Other non-multidimensional array inputs ]) let prediction = try await model.prediction(from: inputFeatures) ``` - Parameter inputs: The named input, or inputs, to make a prediction from. - Returns: The output, or outputs, from the prediction.
static compileModelAt94960(url: string): Promise<string>Swift declarationclass func compileModel(at url: URL) async throws -> URLUsing Swift 'async' idiom.
static compileModelAtCompletionHandler(url: string, handler: ((arg0: SDKHandle) => void)): voidSwift declarationclass func compileModel(at url: URL, completionHandler handler: @escaping (Result<URL, any Error>) -> Void)Compile a .mlmodel asynchronously given its on-disk location. Model compilation may take a considerable amount of time. Use this factory method especially when the caller is on the main thread. - Parameter url: Location of the .mlmodel file. - Parameter handler: When the model compilation completes successfully the completion handler is invoked with a valid URL to the compiled .mlmodelc directory. On failure the completion handler is invoked with an NSError object. The model is compiled to a temporary location on disk. You must move the compiled model to a permanent location if you wish to keep it.
static get availableComputeDevices(): Array<MLComputeDevice>Swift declarationstatic var availableComputeDevices: [MLComputeDevice] { get }The list of available compute devices for CoreML. Use the method to get the list of compute devices that MLModel's prediction can use. The hardware may have other compute devices that are not available to CoreML. Use `MLComputeDevice.allComputeDevices` to get the complete list.
static loadContentsOfConfigurationCompletionHandler(url: string, configuration: MLModelConfiguration, handler: ((arg0: SDKHandle) => void)): voidSwift declarationclass func load(contentsOf url: URL, configuration: MLModelConfiguration = MLModelConfiguration(), completionHandler handler: @escaping (Result<MLModel, any Error>) -> Void)Construct a model asynchronously given the location of its on-disk representation and configuration. Model loading may take time when the model content is not immediately available (e.g. encrypted model). Use this factory method especially when the caller is on the main thread. - Parameter url: Location of its on-disk representation (.mlmodelc directory). - Parameter configuration: Configuration The model configuration - Parameter handler: When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid MLModel instance or NSError object.
static loadContentsOfConfiguration(url: string, configuration?: MLModelConfiguration): Promise<MLModel>Swift declarationclass func load(contentsOf url: URL, configuration: MLModelConfiguration = MLModelConfiguration()) async throws -> MLModelConstruct a model asynchronously given the location of its on-disk representation and configuration. Model loading may take time when the model content is not immediately available (e.g. encrypted model). Use this factory method especially when the caller is on the main thread. - Parameter url: Location of its on-disk representation (.mlmodelc directory). - Parameter configuration: Configuration The model configuration - Returns: A constructed MLModel object.
makeState(): MLStateSwift declarationfunc makeState() -> MLStateCreates a new state object. Core ML framework will allocate the state buffers declared in the model. The allocated state buffers are initialized to zeros. To initialize with different values, use `.withMultiArray(for:)` to get the mutable `MLMultiArray`-view to the state buffer. ```swift // Create state that contains two state buffers: s1 and s2. // Then, initialize s1 to 1.0 and s2 to 2.0. let state = model.makeState() state.withMultiArray(for: "s1") { stateMultiArray in stateMultiArray[0] = 1.0 } state.withMultiArray(for: "s2") { stateMultiArray in stateMultiArray[0] = 2.0 } ```
1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
MLModel.init()
inherited init: cannot prove legal (class declares 4 custom initializers)