Skip to content

Latest commit

 

History

History
251 lines (240 loc) · 35.7 KB

CoreML.md

File metadata and controls

251 lines (240 loc) · 35.7 KB

CoreML

Symbols: 68.7% of Apple's iOS API (463 of 674, exact) · Rows: 13: 8 ✅ 3 🟡 2 ❌ · iOS: 11.0+

Area: Imaging, photos & ML · Apple: CoreML · Issues: area:ml

How isim implements it

  • Adapted: isim parses the model specification itself and runs GLM models only. Xcode-compiled .mlmodelc is undocumented.

API

API / feature Status iOS Notes
Core ML data API (MLMultiArray, MLFeatureValue, MLDictionaryFeatureProvider, MLArrayBatchProvider, MLModelConfiguration, MLModelDescription) ✅ ≤17 tested (shapes, strides, subscripts, feature values)
Core ML models in projects (.mlmodel, .mlpackage; Xcode's generated model classes) ✅ ≤17 adapted: isim build compiles each model in Compile Sources (or a synchronized folder) into <Name>.mlmodelc in the app with isim's format (the spec, what MLModel(contentsOf:) loads; a package's root model from its Manifest.json) instead of Apple's undocumented one, and generates Xcode's Swift classes from the model's description: <Name>Input / <Name>Output (MLFeatureProvider, a property per feature: Int64, Double, String, CVPixelBuffer, MLMultiArray, dictionaries, MLSequence; optional inputs), <Name> (init(configuration:), init(contentsOf:configuration:), load(configuration:) async and with a completion handler, urlOfModelInThisBundle, prediction(input:), prediction(<inputs>:), predictions(inputs:options:)); COREML_CODEGEN_LANGUAGE = None turns generation off. import CoreML re-exports Foundation, as Apple's does (the generated classes use URL and Bundle). Not generated: Objective-C model classes (isim's Core ML has no Objective-C interface yet). What a model can predict is the next row. Tested (HelloCoreMLModels: test_generated_model_classes, test_coreml_models)
Core ML MLModel loading and prediction 🟡 ≤17 adapted: Apple's compiled .mlmodelc format is undocumented and needs Apple's runtime, so Xcode-compiled models fail to load with a clear error (tested); MLModel.compileModel(at:) turns a .mlmodel spec into an isim .mlmodelc; descriptions are read for every model type (with stateDescriptionsByName); predictions run for GLM regressors/classifiers, tree ensembles and neural networks (next rows); ML programs and pipelines fail with a clear error (tested)
Core ML tree ensembles (treeEnsembleRegressor, treeEnsembleClassifier) ✅ ≤17 adapted: isim evaluates the spec's trees on the CPU (branch modes, missing values, base values, softmax / logistic post-transforms, class labels and probabilities). Tested (CoreMLTest: test_coreml_runtime)
Core ML neural networks (neuralNetwork, neuralNetworkRegressor, neuralNetworkClassifier) and MLCustomLayer 🟡 ≤17 adapted: isim runs the network on the CPU, layer by layer: inner product, activations (linear, ReLU, leaky / thresholded ReLU, tanh, scaled tanh, sigmoid, hard sigmoid, ELU, softsign, softplus), batch norm, softmax, add, multiply, concat, reshape, flatten, and custom layers (the app's MLCustomLayer class, found by className); float32 / float16 / raw weights. Other layer types (convolution, pooling, recurrent, …) fail with an error naming the layer. Tested (CoreMLTest)
MLShapedArray, MLShapedArraySlice, MLShapedArrayProtocol, MLShapedArrayScalar ✅ ≤17 adapted (pure Swift): shapes, strides, scalar / index / range subscripts, reshape, expand / squeeze, transpose, concatenation, identity and random arrays, Codable, conversion to and from MLMultiArray and MLFeatureValue. Tested (CoreMLTest)
MLState, MLModel.makeState(), prediction(from:using:options:) ✅ 18.0 adapted: state buffers come from the model description's state features and persist between predictions; withMultiArray(for:) reads and writes them. Tested (CoreMLTest)
MLTensor, MLTensorScalar, MLTensorRangeExpression ✅ 18.0 adapted: an eager CPU tensor (Double storage): creation, broadcasting arithmetic, comparisons, reductions, matmul, shape operations, gather / replacing, padding, resizing, top-k, subscripts, seeded random; shapedArray(of:) materialises it. Tested (CoreMLTest)
MLComputeDevice, MLCPUComputeDevice, MLGPUComputeDevice, MLNeuralEngineComputeDevice, MLComputePlan, MLModelStructure ✅ ≤17 adapted: isim computes on the CPU only, so MLModel.availableComputeDevices and MLComputeDevice.allComputeDevices list the CPU; MLComputePlan.load describes the model's structure (neural network layers, program or pipeline) with every layer on the CPU and no cost estimate. Tested (CoreMLTest)
MLUpdateTask, MLUpdateContext, MLUpdateProgressHandlers, MLParameterKey, MLMetricKey 🟡 ≤17 stub: the types exist so apps compile; on-device training is not implemented and creating an MLUpdateTask throws an .update error. Tested (CoreMLTest)
MLSendableFeatureValue (init(_:) from values, shaped arrays and an MLFeatureValue, init(undefined:), type, isUndefined, isScalar, isShapedArray, the typed values, shapedArrayValue(of:)), MLFeatureValue(_:) from one ✅ 18.0 adapted: a value over isim's immutable MLFeatureValue (issue #852, for Vision's CoreMLFeatureValueObservation). Unverified (no test yet)
Types not yet in isim (iOS 17 and earlier) ❌ ≤17 not implemented, found by the 2026-10 sweep: MLCustomModel, MLModelAsset, MLTask (3 types; with their members under "Not yet in isim")
Types not yet in isim (iOS 18) ❌ 18.0 not implemented, found by the 2026-10 sweep: MLComputePolicy, MLStateConstraint (2 types; with their members under "Not yet in isim")

Not yet in isim

211 symbols Apple documents for iOS that isim does not have (exact; Apple snapshot 2026-10-14). Each links to Apple's documentation.

List