coreml

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package coreml provides Go bindings for the CoreML framework.

Integrate machine learning models into your app.

Use [Core ML](<doc://com.apple.coreml/documentation/CoreML>) to integrate machine learning models into your app. [Core ML](<doc://com.apple.coreml/documentation/CoreML>) provides a unified representation for all models. Your app uses [Core ML](<doc://com.apple.coreml/documentation/CoreML>) APIs and user data to make predictions, and to train or fine-tune models, all on a person’s device.

Core ML models

  • Getting a Core ML Model: Obtain a Core ML model to use in your app.
  • Updating a Model File to a Model Package: Convert a Core ML model file into a model package in Xcode.
  • Integrating a Core ML Model into Your App: Add a simple model to an app, pass input data to the model, and process the model’s predictions.
  • MLModel: An encapsulation of all the details of your machine learning model. (MLPredictionOptions, MLModelDescription, MLParameterKey, MLModelConfiguration, MLOptimizationHints)
  • Model Customization: Expand and modify your model with new layers. (MLCustomLayer, MLCustomModel)
  • Model Personalization: Update your model to adapt to new data. (MLTask, MLUpdateTask)

Model inputs and outputs

  • Making Predictions with a Sequence of Inputs: Integrate a recurrent neural network model to process sequences of inputs.
  • MLFeatureValue: A generic wrapper around an underlying value and the value’s type. (MLImageConstraint, MLFeatureType, MLMultiArray, MLSequence)
  • MLSendableFeatureValue: A sendable feature value.
  • MLFeatureProvider: An interface that represents a collection of values for either a model’s input or its output.
  • MLDictionaryFeatureProvider: A convenience wrapper for the given dictionary of data.
  • MLBatchProvider: An interface that represents a collection of feature providers.
  • MLArrayBatchProvider: A convenience wrapper for batches of feature providers.
  • MLModelAsset: An abstraction of a compiled Core ML model asset.

App integration

  • Downloading and Compiling a Model on the User’s Device: Install Core ML models on the user’s device dynamically at runtime.
  • Model Integration Samples: Integrate tabular, image, and text classifcation models into your app.

Model encryption

  • Generating a Model Encryption Key: Create a model encryption key to encrypt a compiled model or model archive.
  • Encrypting a Model in Your App: Encrypt your app’s built-in model at compile time by adding a compiler flag.

Compute devices

  • MLComputeDevice: Compute devices for framework operations.
  • MLCPUComputeDevice: An object that represents a CPU compute device.
  • MLGPUComputeDevice: An object that represents a GPU compute device.
  • MLNeuralEngineComputeDevice: An object that represents a Neural Engine compute device.
  • MLComputeDeviceProtocol: An interface that represents a compute device type.

Compute plan

  • MLComputePlan: A class representing the compute plan of a model.
  • MLModelStructure: An enum representing the structure of a model.
  • MLComputePolicy: The compute policy determining what compute device, or compute devices, to execute ML workloads on.
  • withMLTensorComputePolicy(_:_:): Calls the given closure within a task-local context using the specified compute policy to influence what compute device tensor operations are executed on.
  • withMLTensorComputePolicy(_:_:): Calls the given closure within a task-local context using the specified compute policy to influence what compute device tensor operations are executed on.

Model state

  • MLState: Handle to the state buffers.
  • MLStateConstraint: Constraint of a state feature value.

Model tensor

  • MLTensor: A multi-dimensional array of numerical or Boolean scalars tailored to ML use cases, containing methods to perform transformations and mathematical operations efficiently using a ML compute device.
  • MLTensorScalar: A type that represents the tensor scalar types supported by the framework.
  • MLTensorRangeExpression: A type that can be used to slice a dimension of a tensor.
  • pointwiseMin(_:_:): Computes the element-wise minimum of two tensors.
  • pointwiseMax(_:_:): Computes the element-wise minimum between two tensors.
  • withMLTensorComputePolicy(_:_:): Calls the given closure within a task-local context using the specified compute policy to influence what compute device tensor operations are executed on.

Model structure

  • MLModelStructure: An enum representing the structure of a model.

Model errors

  • MLModelError: Information about a Core ML model error.
  • MLModelError.Code: Information about a Core ML model error.
  • MLModelErrorDomain: The domain for Core ML errors.

Model deployments

  • MLModelCollection: A set of Core ML models from a model deployment.

Key Types

  • MLFeatureValue - A generic wrapper around an underlying value and the value’s type.
  • MLParameterKey - The keys for the parameter dictionary in a model configuration or a model update context.
  • MLModel - An encapsulation of all the details of your machine learning model.
  • MLMultiArray - A machine learning collection type that stores numeric values in an array with multiple dimensions.
  • MLModelDescription - Information about a model, primarily the input and output format for each feature the model expects, and optional metadata.
  • MLFeatureDescription - The name, type, and constraints of an input or output feature.
  • MLMultiArrayConstraint - The shape and data type constraints for a multidimensional array feature.
  • MLImageSizeConstraint - A list or range of sizes that augment an image constraint’s default size.
  • MLModelConfiguration - The settings for creating or updating a machine learning model.
  • MLSequenceConstraint - The constraints for a sequence feature.

Code generated from Apple documentation. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var MLFeatureValueImageOptions struct {
	// CropAndScale: The option you use to crop and scale an image when creating an image feature value.
	CropAndScale MLFeatureValueImageOption
	// CropRect: The option you use to crop an image when creating an image feature value.
	CropRect MLFeatureValueImageOption
}

MLFeatureValueImageOptions provides typed accessors for MLFeatureValueImageOption constants.

View Source
var (
	// MLModelErrorDomain is the domain for Core ML errors.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLModelErrorDomain
	MLModelErrorDomain string
)

Functions

func NewErrorBlock

func NewErrorBlock(handler ErrorHandler) (objc.ID, func())

NewErrorBlock wraps a Go ErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewMLComputePlanErrorBlock

func NewMLComputePlanErrorBlock(handler MLComputePlanErrorHandler) (objc.ID, func())

NewMLComputePlanErrorBlock wraps a Go MLComputePlanErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [MLComputePlan.LoadContentsOfURLConfigurationCompletionHandler]
  • [MLComputePlan.LoadModelAssetConfigurationCompletionHandler]

func NewMLModelDescriptionErrorBlock

func NewMLModelDescriptionErrorBlock(handler MLModelDescriptionErrorHandler) (objc.ID, func())

NewMLModelDescriptionErrorBlock wraps a Go MLModelDescriptionErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewMLModelErrorBlock

func NewMLModelErrorBlock(handler MLModelErrorHandler) (objc.ID, func())

NewMLModelErrorBlock wraps a Go MLModelErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [MLModel.LoadModelAssetConfigurationCompletionHandler]

func NewMLModelStructureErrorBlock

func NewMLModelStructureErrorBlock(handler MLModelStructureErrorHandler) (objc.ID, func())

NewMLModelStructureErrorBlock wraps a Go MLModelStructureErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [MLModelStructure.LoadContentsOfURLCompletionHandler]
  • [MLModelStructure.LoadModelAssetCompletionHandler]

func NewMLUpdateContextBlock

func NewMLUpdateContextBlock(handler MLUpdateContextHandler) (objc.ID, func())

NewMLUpdateContextBlock wraps a Go MLUpdateContextHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewVoidBlock

func NewVoidBlock(handler VoidHandler) (objc.ID, func())

NewVoidBlock wraps a Go VoidHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

Types

type ErrorHandler

type ErrorHandler = func(error)

ErrorHandler handles The closures the task calls during the update process. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

type IMLArrayBatchProvider

type IMLArrayBatchProvider interface {
	objectivec.IObject
	MLBatchProvider

	// Creates the batch provider based on the array of feature providers.
	InitWithFeatureProviderArray(array []objectivec.IObject) MLArrayBatchProvider
	// Creates a batch provider based on feature names and their associated arrays of data.
	InitWithDictionaryError(dictionary foundation.INSDictionary) (MLArrayBatchProvider, error)

	// The array of feature providers.
	Array() []objectivec.IObject
}

An interface definition for the MLArrayBatchProvider class.

Creating a batch provider

  • [IMLArrayBatchProvider.InitWithFeatureProviderArray]: Creates the batch provider based on the array of feature providers.
  • [IMLArrayBatchProvider.InitWithDictionaryError]: Creates a batch provider based on feature names and their associated arrays of data.

Accessing the feature providers

  • [IMLArrayBatchProvider.Array]: The array of feature providers.

See: https://developer.apple.com/documentation/CoreML/MLArrayBatchProvider

type IMLComputePlan

type IMLComputePlan interface {
	objectivec.IObject

	// The model structure.
	ModelStructure() IMLModelStructure

	// Returns The anticipated compute devices that would be used for executing an ML Program operation.
	ComputeDeviceUsageForMLProgramOperation(operation IMLModelStructureProgramOperation) IMLComputePlanDeviceUsage
	// Returns the anticipated compute devices that would be used for executing a NeuralNetwork layer.
	ComputeDeviceUsageForNeuralNetworkLayer(layer IMLModelStructureNeuralNetworkLayer) IMLComputePlanDeviceUsage

	// Returns the estimated cost of executing an ML Program operation.
	EstimatedCostOfMLProgramOperation(operation IMLModelStructureProgramOperation) IMLComputePlanCost
}

An interface definition for the MLComputePlan class.

Getting the model structure

  • [IMLComputePlan.ModelStructure]: The model structure.

Getting the device usage

  • [IMLComputePlan.ComputeDeviceUsageForMLProgramOperation]: Returns The anticipated compute devices that would be used for executing an ML Program operation.
  • [IMLComputePlan.ComputeDeviceUsageForNeuralNetworkLayer]: Returns the anticipated compute devices that would be used for executing a NeuralNetwork layer.

Getting the estimated cost

  • [IMLComputePlan.EstimatedCostOfMLProgramOperation]: Returns the estimated cost of executing an ML Program operation.

See: https://developer.apple.com/documentation/CoreML/MLComputePlan-85vdw

type IMLComputePlanCost

type IMLComputePlanCost interface {
	objectivec.IObject

	// The estimated workload of executing the operation over the total model execution. The value is between [0.0, 1.0].
	Weight() float64
}

An interface definition for the MLComputePlanCost class.

Accessing the weight

  • [IMLComputePlanCost.Weight]: The estimated workload of executing the operation over the total model execution. The value is between [0.0, 1.0].

See: https://developer.apple.com/documentation/CoreML/MLComputePlanCost

type IMLComputePlanDeviceUsage

type IMLComputePlanDeviceUsage interface {
	objectivec.IObject

	// The compute device that the framework prefers to execute the layer/operation.
	PreferredComputeDevice() MLComputeDeviceProtocol
	// The compute devices that can execute the layer/operation.
	SupportedComputeDevices() []objectivec.IObject
}

An interface definition for the MLComputePlanDeviceUsage class.

Getting the compute device

  • [IMLComputePlanDeviceUsage.PreferredComputeDevice]: The compute device that the framework prefers to execute the layer/operation.
  • [IMLComputePlanDeviceUsage.SupportedComputeDevices]: The compute devices that can execute the layer/operation.

See: https://developer.apple.com/documentation/CoreML/MLComputePlanDeviceUsage

type IMLDictionaryConstraint

type IMLDictionaryConstraint interface {
	objectivec.IObject

	// The key type for the dictionary.
	KeyType() MLFeatureType

	// The constraint for a dictionary feature.
	DictionaryConstraint() IMLDictionaryConstraint
	SetDictionaryConstraint(value IMLDictionaryConstraint)
	// The size and format constraints for an image feature.
	ImageConstraint() IMLImageConstraint
	SetImageConstraint(value IMLImageConstraint)
	// The constraints on a multidimensional array feature.
	MultiArrayConstraint() IMLMultiArrayConstraint
	SetMultiArrayConstraint(value IMLMultiArrayConstraint)
	// The constraints for a sequence feature.
	SequenceConstraint() IMLSequenceConstraint
	SetSequenceConstraint(value IMLSequenceConstraint)
	// The state feature value constraint.
	StateConstraint() IMLStateConstraint
	SetStateConstraint(value IMLStateConstraint)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLDictionaryConstraint class.

Accessing the constraint

  • [IMLDictionaryConstraint.KeyType]: The key type for the dictionary.

See: https://developer.apple.com/documentation/CoreML/MLDictionaryConstraint

type IMLDictionaryFeatureProvider

type IMLDictionaryFeatureProvider interface {
	objectivec.IObject
	MLFeatureProvider

	// Creates the feature provider based on a dictionary.
	InitWithDictionaryError(dictionary foundation.INSDictionary) (MLDictionaryFeatureProvider, error)

	// Subscript interface for the feature provider to pass through to the dictionary.
	ObjectForKeyedSubscript(featureName string) IMLFeatureValue
	// The backing dictionary.
	Dictionary() foundation.INSDictionary

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLDictionaryFeatureProvider class.

Creating the provider

  • [IMLDictionaryFeatureProvider.InitWithDictionaryError]: Creates the feature provider based on a dictionary.

Accessing the features

  • [IMLDictionaryFeatureProvider.ObjectForKeyedSubscript]: Subscript interface for the feature provider to pass through to the dictionary.
  • [IMLDictionaryFeatureProvider.Dictionary]: The backing dictionary.

See: https://developer.apple.com/documentation/CoreML/MLDictionaryFeatureProvider

type IMLFeatureDescription

type IMLFeatureDescription interface {
	objectivec.IObject

	// The name of this feature.
	Name() string
	// The type of this feature.
	Type() MLFeatureType
	// A Boolean value that indicates whether this feature is optional.
	Optional() bool

	// Checks whether the model will accept an input feature value.
	IsAllowedValue(value IMLFeatureValue) bool

	// The state feature value constraint.
	StateConstraint() IMLStateConstraint
	// The size and format constraints for an image feature.
	ImageConstraint() IMLImageConstraint
	// The constraint for a dictionary feature.
	DictionaryConstraint() IMLDictionaryConstraint
	// The constraints on a multidimensional array feature.
	MultiArrayConstraint() IMLMultiArrayConstraint
	// The constraints for a sequence feature.
	SequenceConstraint() IMLSequenceConstraint

	// A dictionary of input feature descriptions, which the model keys by the input’s name.
	InputDescriptionsByName() IMLFeatureDescription
	SetInputDescriptionsByName(value IMLFeatureDescription)
	// A dictionary of output feature descriptions, which the model keys by the output’s name.
	OutputDescriptionsByName() IMLFeatureDescription
	SetOutputDescriptionsByName(value IMLFeatureDescription)
	// Description of the state features.
	StateDescriptionsByName() IMLFeatureDescription
	SetStateDescriptionsByName(value IMLFeatureDescription)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLFeatureDescription class.

Inspecting a feature

  • [IMLFeatureDescription.Name]: The name of this feature.
  • [IMLFeatureDescription.Type]: The type of this feature.
  • [IMLFeatureDescription.Optional]: A Boolean value that indicates whether this feature is optional.

Checking for validity

  • [IMLFeatureDescription.IsAllowedValue]: Checks whether the model will accept an input feature value.

Accessing feature constraints

  • [IMLFeatureDescription.StateConstraint]: The state feature value constraint.
  • [IMLFeatureDescription.ImageConstraint]: The size and format constraints for an image feature.
  • [IMLFeatureDescription.DictionaryConstraint]: The constraint for a dictionary feature.
  • [IMLFeatureDescription.MultiArrayConstraint]: The constraints on a multidimensional array feature.
  • [IMLFeatureDescription.SequenceConstraint]: The constraints for a sequence feature.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription

type IMLFeatureValue

type IMLFeatureValue interface {
	objectivec.IObject

	// The type of the feature value.
	Type() MLFeatureType

	// A Boolean value that indicates whether the feature value is undefined or missing.
	Undefined() bool
	// The underlying integer of the feature value.
	Int64Value() int64
	// The underlying double of the feature value.
	DoubleValue() float64
	// The underlying string of the feature value.
	StringValue() string
	// The underlying image of the feature value as a pixel buffer.
	ImageBufferValue() corevideo.CVImageBufferRef
	// The underlying multiarray of the feature value.
	MultiArrayValue() IMLMultiArray
	// The underlying sequence of the feature value.
	SequenceValue() IMLSequence
	// The underlying dictionary of the feature value.
	DictionaryValue() foundation.INSDictionary

	// Returns a Boolean value that indicates whether a feature value is equal to another.
	IsEqualToFeatureValue(value IMLFeatureValue) bool

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLFeatureValue class.

Accessing the feature’s type

  • [IMLFeatureValue.Type]: The type of the feature value.

Accessing the feature’s value

  • [IMLFeatureValue.Undefined]: A Boolean value that indicates whether the feature value is undefined or missing.
  • [IMLFeatureValue.Int64Value]: The underlying integer of the feature value.
  • [IMLFeatureValue.DoubleValue]: The underlying double of the feature value.
  • [IMLFeatureValue.StringValue]: The underlying string of the feature value.
  • [IMLFeatureValue.ImageBufferValue]: The underlying image of the feature value as a pixel buffer.
  • [IMLFeatureValue.MultiArrayValue]: The underlying multiarray of the feature value.
  • [IMLFeatureValue.SequenceValue]: The underlying sequence of the feature value.
  • [IMLFeatureValue.DictionaryValue]: The underlying dictionary of the feature value.

Comparing feature values

  • [IMLFeatureValue.IsEqualToFeatureValue]: Returns a Boolean value that indicates whether a feature value is equal to another.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue

type IMLGPUComputeDevice

type IMLGPUComputeDevice interface {
	objectivec.IObject
	MLComputeDeviceProtocol

	// The device that represents the underlying metal device.
	MetalDevice() objectivec.IObject
}

An interface definition for the MLGPUComputeDevice class.

Getting the metal device

  • [IMLGPUComputeDevice.MetalDevice]: The device that represents the underlying metal device.

See: https://developer.apple.com/documentation/CoreML/MLGPUComputeDevice

type IMLImageConstraint

type IMLImageConstraint interface {
	objectivec.IObject

	// The model’s default width for an image feature.
	PixelsWide() int
	// The model’s default height for an image feature.
	PixelsHigh() int
	// The model’s pixel format for an image feature.
	PixelFormatType() uint32

	// Additional sizes this image feature supports.
	SizeConstraint() IMLImageSizeConstraint

	// The size and format constraints for an image feature.
	ImageConstraint() IMLImageConstraint
	SetImageConstraint(value IMLImageConstraint)
	// The type of this feature.
	Type() MLFeatureType
	SetType(value MLFeatureType)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLImageConstraint class.

Accessing the constraints

  • [IMLImageConstraint.PixelsWide]: The model’s default width for an image feature.
  • [IMLImageConstraint.PixelsHigh]: The model’s default height for an image feature.
  • [IMLImageConstraint.PixelFormatType]: The model’s pixel format for an image feature.

Inspecting acceptable sizes

  • [IMLImageConstraint.SizeConstraint]: Additional sizes this image feature supports.

See: https://developer.apple.com/documentation/CoreML/MLImageConstraint

type IMLImageSize

type IMLImageSize interface {
	objectivec.IObject

	// The height of an image feature in pixels.
	PixelsHigh() int
	// The width of an image feature in pixels.
	PixelsWide() int

	// An array of image sizes a model’s image feature accepts as input or produces as output.
	EnumeratedImageSizes() IMLImageSize
	SetEnumeratedImageSizes(value IMLImageSize)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLImageSize class.

Accessing an image size

  • [IMLImageSize.PixelsHigh]: The height of an image feature in pixels.
  • [IMLImageSize.PixelsWide]: The width of an image feature in pixels.

See: https://developer.apple.com/documentation/CoreML/MLImageSize

type IMLImageSizeConstraint

type IMLImageSizeConstraint interface {
	objectivec.IObject

	// Indicator of which properties to inspect for this image size constraint.
	Type() MLImageSizeConstraintType

	// The range of widths a model’s image feature accepts as input or produces as output.
	PixelsWideRange() foundation.NSRange
	// The range of heights a model’s image feature accepts as input or produces as output.
	PixelsHighRange() foundation.NSRange

	// An array of image sizes a model’s image feature accepts as input or produces as output.
	EnumeratedImageSizes() []MLImageSize

	// The model’s default height for an image feature.
	PixelsHigh() int
	SetPixelsHigh(value int)
	// The model’s default width for an image feature.
	PixelsWide() int
	SetPixelsWide(value int)
	// Additional sizes this image feature supports.
	SizeConstraint() IMLImageSizeConstraint
	SetSizeConstraint(value IMLImageSizeConstraint)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLImageSizeConstraint class.

Determining relevant constraints

  • [IMLImageSizeConstraint.Type]: Indicator of which properties to inspect for this image size constraint.

Accessing the image size ranges

  • [IMLImageSizeConstraint.PixelsWideRange]: The range of widths a model’s image feature accepts as input or produces as output.
  • [IMLImageSizeConstraint.PixelsHighRange]: The range of heights a model’s image feature accepts as input or produces as output.

Accessing the enumerated image sizes

  • [IMLImageSizeConstraint.EnumeratedImageSizes]: An array of image sizes a model’s image feature accepts as input or produces as output.

See: https://developer.apple.com/documentation/CoreML/MLImageSizeConstraint

type IMLKey

type IMLKey interface {
	objectivec.IObject

	// The name of the machine learning key.
	Name() string
	// The applicable scope of the machine learning key.
	Scope() string

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLKey class.

Retrieving a key’s information

  • [IMLKey.Name]: The name of the machine learning key.
  • [IMLKey.Scope]: The applicable scope of the machine learning key.

See: https://developer.apple.com/documentation/CoreML/MLKey

type IMLMetricKey

type IMLMetricKey interface {
	IMLKey

	// The training metrics of the model for the update task, contained in a dictionary.
	Metrics() IMLMetricKey
	SetMetrics(value IMLMetricKey)
}

An interface definition for the MLMetricKey class.

See: https://developer.apple.com/documentation/CoreML/MLMetricKey

type IMLModel

type IMLModel interface {
	objectivec.IObject

	PredictionFromFeaturesError(input objectivec.IObject) (objectivec.IObject, error)
	PredictionFromFeaturesOptionsError(input objectivec.IObject, options IMLPredictionOptions) (objectivec.IObject, error)
	// Generates predictions for each input feature provider within the batch provider.
	PredictionsFromBatchError(inputBatch MLBatchProvider) (MLBatchProvider, error)
	// Generates a prediction for each input feature provider within the batch provider using the prediction options.
	PredictionsFromBatchOptionsError(inputBatch MLBatchProvider, options IMLPredictionOptions) (MLBatchProvider, error)
	PredictionFromFeaturesUsingStateError(inputFeatures objectivec.IObject, state IMLState) (objectivec.IObject, error)
	PredictionFromFeaturesUsingStateOptionsError(inputFeatures objectivec.IObject, state IMLState, options IMLPredictionOptions) (objectivec.IObject, error)

	// The list of available compute devices that the model’s prediction methods use.
	AvailableComputeDevices() objectivec.IObject
	SetAvailableComputeDevices(value objectivec.IObject)
	// The configuration of the model set during initialization.
	Configuration() IMLModelConfiguration
	// Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.
	ModelDescription() IMLModelDescription
	// Returns a model parameter value for a key.
	ParameterValueForKeyError(key IMLParameterKey) (objectivec.IObject, error)

	// A dictionary of the model’s creation information, such as its description, author, version, and license.
	Metadata() MLModelMetadataKey
	SetMetadata(value MLModelMetadataKey)
}

An interface definition for the MLModel class.

Making predictions

  • [IMLModel.PredictionFromFeaturesError]
  • [IMLModel.PredictionFromFeaturesOptionsError]
  • [IMLModel.PredictionsFromBatchError]: Generates predictions for each input feature provider within the batch provider.
  • [IMLModel.PredictionsFromBatchOptionsError]: Generates a prediction for each input feature provider within the batch provider using the prediction options.
  • [IMLModel.PredictionFromFeaturesUsingStateError]
  • [IMLModel.PredictionFromFeaturesUsingStateOptionsError]

Inspecting a model

  • [IMLModel.AvailableComputeDevices]: The list of available compute devices that the model’s prediction methods use.
  • [IMLModel.SetAvailableComputeDevices]
  • [IMLModel.Configuration]: The configuration of the model set during initialization.
  • [IMLModel.ModelDescription]: Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.
  • [IMLModel.ParameterValueForKeyError]: Returns a model parameter value for a key.

See: https://developer.apple.com/documentation/CoreML/MLModel

type IMLModelAsset

type IMLModelAsset interface {
	objectivec.IObject

	// The list of function names in the model asset.
	FunctionNamesWithCompletionHandler(handler ErrorHandler)

	// The default model descripton.
	ModelDescriptionWithCompletionHandler(handler MLModelDescriptionErrorHandler)
	// The model descripton for a specified function.
	ModelDescriptionOfFunctionNamedCompletionHandler(functionName string, handler MLModelDescriptionErrorHandler)
}

An interface definition for the MLModelAsset class.

Getting function names

  • [IMLModelAsset.FunctionNamesWithCompletionHandler]: The list of function names in the model asset.

Getting the model description

  • [IMLModelAsset.ModelDescriptionWithCompletionHandler]: The default model descripton.
  • [IMLModelAsset.ModelDescriptionOfFunctionNamedCompletionHandler]: The model descripton for a specified function.

See: https://developer.apple.com/documentation/CoreML/MLModelAsset

type IMLModelConfiguration

type IMLModelConfiguration interface {
	objectivec.IObject

	// Function name that [MLModel] will use.
	FunctionName() string
	SetFunctionName(value string)
	// A human readable name of a model for display purposes.
	ModelDisplayName() string
	SetModelDisplayName(value string)
	// A dictionary of configuration settings your app can override when loading a model.
	Parameters() foundation.INSDictionary
	SetParameters(value foundation.INSDictionary)

	// The metal device you prefer this model use to make predictions (inference) and update the model.
	PreferredMetalDevice() objectivec.IObject
	SetPreferredMetalDevice(value objectivec.IObject)
	// A Boolean value that determines whether to allow low-precision accumulation on a GPU.
	AllowLowPrecisionAccumulationOnGPU() bool
	SetAllowLowPrecisionAccumulationOnGPU(value bool)

	// The processing unit or units the model uses to make predictions.
	ComputeUnits() MLComputeUnits
	SetComputeUnits(value MLComputeUnits)

	// A group of hints for CoreML to optimize
	OptimizationHints() IMLOptimizationHints
	SetOptimizationHints(value IMLOptimizationHints)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLModelConfiguration class.

Configuring model parameters

  • [IMLModelConfiguration.FunctionName]: Function name that MLModel will use.
  • [IMLModelConfiguration.SetFunctionName]
  • [IMLModelConfiguration.ModelDisplayName]: A human readable name of a model for display purposes.
  • [IMLModelConfiguration.SetModelDisplayName]
  • [IMLModelConfiguration.Parameters]: A dictionary of configuration settings your app can override when loading a model.
  • [IMLModelConfiguration.SetParameters]

Configuring GPU usage

  • [IMLModelConfiguration.PreferredMetalDevice]: The metal device you prefer this model use to make predictions (inference) and update the model.
  • [IMLModelConfiguration.SetPreferredMetalDevice]
  • [IMLModelConfiguration.AllowLowPrecisionAccumulationOnGPU]: A Boolean value that determines whether to allow low-precision accumulation on a GPU.
  • [IMLModelConfiguration.SetAllowLowPrecisionAccumulationOnGPU]

Allowing access to processing units

  • [IMLModelConfiguration.ComputeUnits]: The processing unit or units the model uses to make predictions.
  • [IMLModelConfiguration.SetComputeUnits]

Getting optimization hints

  • [IMLModelConfiguration.OptimizationHints]: A group of hints for CoreML to optimize
  • [IMLModelConfiguration.SetOptimizationHints]

See: https://developer.apple.com/documentation/CoreML/MLModelConfiguration

type IMLModelDescription

type IMLModelDescription interface {
	objectivec.IObject

	// Description of the state features.
	StateDescriptionsByName() foundation.INSDictionary
	// A dictionary of input feature descriptions, which the model keys by the input’s name.
	InputDescriptionsByName() foundation.INSDictionary
	// A dictionary of output feature descriptions, which the model keys by the output’s name.
	OutputDescriptionsByName() foundation.INSDictionary

	// An array of labels, which can be either strings or a numbers, for classifier models.
	ClassLabels() []objectivec.IObject
	// A dictionary of the model’s creation information, such as its description, author, version, and license.
	Metadata() foundation.INSDictionary

	// The name of the primary prediction feature output description.
	PredictedFeatureName() string
	// The name of the feature output description for all probabilities of a prediction.
	PredictedProbabilitiesName() string

	// A Boolean value that indicates whether you can update the model with additional training.
	IsUpdatable() bool
	// A dictionary of the training input feature descriptions, which the model keys by the input’s name.
	TrainingInputDescriptionsByName() foundation.INSDictionary
	// A dictionary of the descriptions for the model’s parameters.
	ParameterDescriptionsByKey() foundation.INSDictionary

	// The list of available compute devices that the model’s prediction methods use.
	AvailableComputeDevices() objectivec.IObject
	SetAvailableComputeDevices(value objectivec.IObject)
	// The configuration of the model set during initialization.
	Configuration() IMLModelConfiguration
	SetConfiguration(value IMLModelConfiguration)
	// Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.
	ModelDescription() IMLModelDescription
	SetModelDescription(value IMLModelDescription)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLModelDescription class.

Accessing feature descriptions

  • [IMLModelDescription.StateDescriptionsByName]: Description of the state features.
  • [IMLModelDescription.InputDescriptionsByName]: A dictionary of input feature descriptions, which the model keys by the input’s name.
  • [IMLModelDescription.OutputDescriptionsByName]: A dictionary of output feature descriptions, which the model keys by the output’s name.

Accessing metadata

  • [IMLModelDescription.ClassLabels]: An array of labels, which can be either strings or a numbers, for classifier models.
  • [IMLModelDescription.Metadata]: A dictionary of the model’s creation information, such as its description, author, version, and license.

Accessing prediction names

  • [IMLModelDescription.PredictedFeatureName]: The name of the primary prediction feature output description.
  • [IMLModelDescription.PredictedProbabilitiesName]: The name of the feature output description for all probabilities of a prediction.

Accessing update descriptions

  • [IMLModelDescription.IsUpdatable]: A Boolean value that indicates whether you can update the model with additional training.
  • [IMLModelDescription.TrainingInputDescriptionsByName]: A dictionary of the training input feature descriptions, which the model keys by the input’s name.
  • [IMLModelDescription.ParameterDescriptionsByKey]: A dictionary of the descriptions for the model’s parameters.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription

type IMLModelStructure

type IMLModelStructure interface {
	objectivec.IObject

	// If the model is of NeuralNetwork type then it is the structure of the NeuralNetwork otherwise `nil`.
	NeuralNetwork() IMLModelStructureNeuralNetwork
	// If the model is of Pipeline type then it is the structure of the Pipeline otherwise `nil`.
	Pipeline() IMLModelStructurePipeline
	// If the model is of ML Program type then it is the structure of the ML Program otherwise `nil`.
	Program() IMLModelStructureProgram
}

An interface definition for the MLModelStructure class.

Model structures

  • [IMLModelStructure.NeuralNetwork]: If the model is of NeuralNetwork type then it is the structure of the NeuralNetwork otherwise `nil`.
  • [IMLModelStructure.Pipeline]: If the model is of Pipeline type then it is the structure of the Pipeline otherwise `nil`.
  • [IMLModelStructure.Program]: If the model is of ML Program type then it is the structure of the ML Program otherwise `nil`.

See: https://developer.apple.com/documentation/CoreML/MLModelStructure-c.class

type IMLModelStructureNeuralNetwork

type IMLModelStructureNeuralNetwork interface {
	objectivec.IObject

	// The topologically sorted layers in the NeuralNetwork.
	Layers() []MLModelStructureNeuralNetworkLayer
}

An interface definition for the MLModelStructureNeuralNetwork class.

Accessing the layers

  • [IMLModelStructureNeuralNetwork.Layers]: The topologically sorted layers in the NeuralNetwork.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureNeuralNetwork

type IMLModelStructureNeuralNetworkLayer

type IMLModelStructureNeuralNetworkLayer interface {
	objectivec.IObject

	// The input names.
	InputNames() []string
	// The layer name.
	Name() string
	// The output names.
	OutputNames() []string
	// The type of the layer, e,g, “elementwise”, “pooling”, etc.
	Type() string
}

An interface definition for the MLModelStructureNeuralNetworkLayer class.

Accessing the network layer properties

  • [IMLModelStructureNeuralNetworkLayer.InputNames]: The input names.
  • [IMLModelStructureNeuralNetworkLayer.Name]: The layer name.
  • [IMLModelStructureNeuralNetworkLayer.OutputNames]: The output names.
  • [IMLModelStructureNeuralNetworkLayer.Type]: The type of the layer, e,g, “elementwise”, “pooling”, etc.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureNeuralNetworkLayer

type IMLModelStructurePipeline

type IMLModelStructurePipeline interface {
	objectivec.IObject

	// The names of the sub models in the pipeline.
	SubModelNames() []string
	// The structure of the sub models in the pipeline.
	SubModels() []MLModelStructure
}

An interface definition for the MLModelStructurePipeline class.

Accessing the models and model names

  • [IMLModelStructurePipeline.SubModelNames]: The names of the sub models in the pipeline.
  • [IMLModelStructurePipeline.SubModels]: The structure of the sub models in the pipeline.

See: https://developer.apple.com/documentation/CoreML/MLModelStructurePipeline

type IMLModelStructureProgram

type IMLModelStructureProgram interface {
	objectivec.IObject

	// The functions in the program.
	Functions() foundation.INSDictionary
}

An interface definition for the MLModelStructureProgram class.

Accessing the program functions

  • [IMLModelStructureProgram.Functions]: The functions in the program.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgram

type IMLModelStructureProgramArgument

type IMLModelStructureProgramArgument interface {
	objectivec.IObject

	// The array of bindings.
	Bindings() []MLModelStructureProgramBinding
}

An interface definition for the MLModelStructureProgramArgument class.

Accessing the bindings

  • [IMLModelStructureProgramArgument.Bindings]: The array of bindings.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramArgument

type IMLModelStructureProgramBinding

type IMLModelStructureProgramBinding interface {
	objectivec.IObject

	// The name of the variable in the Program.
	Name() string
	// The compile time constant value in the Program.
	Value() IMLModelStructureProgramValue
}

An interface definition for the MLModelStructureProgramBinding class.

Accessing the program binding properties

  • [IMLModelStructureProgramBinding.Name]: The name of the variable in the Program.
  • [IMLModelStructureProgramBinding.Value]: The compile time constant value in the Program.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramBinding

type IMLModelStructureProgramBlock

type IMLModelStructureProgramBlock interface {
	objectivec.IObject

	// The named inputs to the block.
	Inputs() []MLModelStructureProgramNamedValueType
	// The list of topologically sorted operations in the block.
	Operations() []MLModelStructureProgramOperation
	// The output names.
	OutputNames() []string
}

An interface definition for the MLModelStructureProgramBlock class.

Accessing the program block properties

  • [IMLModelStructureProgramBlock.Inputs]: The named inputs to the block.
  • [IMLModelStructureProgramBlock.Operations]: The list of topologically sorted operations in the block.
  • [IMLModelStructureProgramBlock.OutputNames]: The output names.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramBlock

type IMLModelStructureProgramFunction

type IMLModelStructureProgramFunction interface {
	objectivec.IObject

	// The active block in the function.
	Block() IMLModelStructureProgramBlock
	// The named inputs to the function.
	Inputs() []MLModelStructureProgramNamedValueType
}

An interface definition for the MLModelStructureProgramFunction class.

Accessing the program function properties

  • [IMLModelStructureProgramFunction.Block]: The active block in the function.
  • [IMLModelStructureProgramFunction.Inputs]: The named inputs to the function.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramFunction

type IMLModelStructureProgramNamedValueType

type IMLModelStructureProgramNamedValueType interface {
	objectivec.IObject

	// The name of the parameter.
	Name() string
	// The type of the parameter.
	Type() IMLModelStructureProgramValueType
}

An interface definition for the MLModelStructureProgramNamedValueType class.

Accessing the value type properties

  • [IMLModelStructureProgramNamedValueType.Name]: The name of the parameter.
  • [IMLModelStructureProgramNamedValueType.Type]: The type of the parameter.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramNamedValueType

type IMLModelStructureProgramOperation

type IMLModelStructureProgramOperation interface {
	objectivec.IObject

	// Nested blocks for loops and conditionals, e.g., a conditional block will have two entries here.
	Blocks() []MLModelStructureProgramBlock
	// The arguments to the Operation.
	Inputs() foundation.INSDictionary
	// The name of the operator, e.g., “conv”, “pool”, “softmax”, etc.
	OperatorName() string
	// The outputs of the Operation.
	Outputs() []MLModelStructureProgramNamedValueType
}

An interface definition for the MLModelStructureProgramOperation class.

Accessing the program operation properties

  • [IMLModelStructureProgramOperation.Blocks]: Nested blocks for loops and conditionals, e.g., a conditional block will have two entries here.
  • [IMLModelStructureProgramOperation.Inputs]: The arguments to the Operation.
  • [IMLModelStructureProgramOperation.OperatorName]: The name of the operator, e.g., “conv”, “pool”, “softmax”, etc.
  • [IMLModelStructureProgramOperation.Outputs]: The outputs of the Operation.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramOperation

type IMLModelStructureProgramValue

type IMLModelStructureProgramValue interface {
	objectivec.IObject
}

An interface definition for the MLModelStructureProgramValue class.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramValue

type IMLMultiArray

type IMLMultiArray interface {
	objectivec.IObject

	// Creates a multidimensional array with a shape and type.
	InitWithShapeDataTypeError(shape []foundation.NSNumber, dataType MLMultiArrayDataType) (MLMultiArray, error)
	// Creates a multiarray from a data pointer.
	InitWithDataPointerShapeDataTypeStridesDeallocatorError(dataPointer unsafe.Pointer, shape []foundation.NSNumber, dataType MLMultiArrayDataType, strides []foundation.NSNumber, deallocator func(unsafe.Pointer)) (MLMultiArray, error)
	// Creates a multiarray sharing the surface of a pixel buffer.
	InitWithPixelBufferShape(pixelBuffer corevideo.CVImageBufferRef, shape []foundation.NSNumber) MLMultiArray

	// The total number of elements in the multiarray.
	Count() int
	// The underlying type of the multiarray.
	DataType() MLMultiArrayDataType
	// The multiarray’s multidimensional shape as a number array in which each element’s value is the size of the corresponding dimension.
	Shape() []foundation.NSNumber
	// A number array in which each element is the number of memory locations that span the length of the corresponding dimension.
	Strides() []foundation.NSNumber

	// Transfer the contents to the destination multi-array.
	TransferToMultiArray(destinationMultiArray IMLMultiArray)

	// A reference to the multiarray’s underlying pixel buffer.
	PixelBuffer() corevideo.CVImageBufferRef

	// A dictionary of input feature descriptions, which the model keys by the input’s name.
	InputDescriptionsByName() IMLFeatureDescription
	SetInputDescriptionsByName(value IMLFeatureDescription)
	// Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.
	ModelDescription() IMLModelDescription
	SetModelDescription(value IMLModelDescription)
	// The constraints on a multidimensional array feature.
	MultiArrayConstraint() IMLMultiArrayConstraint
	SetMultiArrayConstraint(value IMLMultiArrayConstraint)
	// A dictionary of output feature descriptions, which the model keys by the output’s name.
	OutputDescriptionsByName() IMLFeatureDescription
	SetOutputDescriptionsByName(value IMLFeatureDescription)
	// The constraint on the shape of the multiarray.
	ShapeConstraint() IMLMultiArrayShapeConstraint
	SetShapeConstraint(value IMLMultiArrayShapeConstraint)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLMultiArray class.

Creating a multiarray

  • [IMLMultiArray.InitWithShapeDataTypeError]: Creates a multidimensional array with a shape and type.
  • [IMLMultiArray.InitWithDataPointerShapeDataTypeStridesDeallocatorError]: Creates a multiarray from a data pointer.
  • [IMLMultiArray.InitWithPixelBufferShape]: Creates a multiarray sharing the surface of a pixel buffer.

Inspecting a multiarray

  • [IMLMultiArray.Count]: The total number of elements in the multiarray.
  • [IMLMultiArray.DataType]: The underlying type of the multiarray.
  • [IMLMultiArray.Shape]: The multiarray’s multidimensional shape as a number array in which each element’s value is the size of the corresponding dimension.
  • [IMLMultiArray.Strides]: A number array in which each element is the number of memory locations that span the length of the corresponding dimension.

Transfering the contents

  • [IMLMultiArray.TransferToMultiArray]: Transfer the contents to the destination multi-array.

Accessing a multiarray’s elements

  • [IMLMultiArray.PixelBuffer]: A reference to the multiarray’s underlying pixel buffer.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray

type IMLMultiArrayConstraint

type IMLMultiArrayConstraint interface {
	objectivec.IObject

	// The shape of the multi array.
	Shape() []foundation.NSNumber
	// The type for the multi array.
	DataType() MLMultiArrayDataType
	// The constraint on the shape of the multiarray.
	ShapeConstraint() IMLMultiArrayShapeConstraint

	// The constraint for a dictionary feature.
	DictionaryConstraint() IMLDictionaryConstraint
	SetDictionaryConstraint(value IMLDictionaryConstraint)
	// The size and format constraints for an image feature.
	ImageConstraint() IMLImageConstraint
	SetImageConstraint(value IMLImageConstraint)
	// The constraints on a multidimensional array feature.
	MultiArrayConstraint() IMLMultiArrayConstraint
	SetMultiArrayConstraint(value IMLMultiArrayConstraint)
	// The constraints for a sequence feature.
	SequenceConstraint() IMLSequenceConstraint
	SetSequenceConstraint(value IMLSequenceConstraint)
	// The state feature value constraint.
	StateConstraint() IMLStateConstraint
	SetStateConstraint(value IMLStateConstraint)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLMultiArrayConstraint class.

Accessing the Constraints

  • [IMLMultiArrayConstraint.Shape]: The shape of the multi array.
  • [IMLMultiArrayConstraint.DataType]: The type for the multi array.
  • [IMLMultiArrayConstraint.ShapeConstraint]: The constraint on the shape of the multiarray.

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayConstraint

type IMLMultiArrayShapeConstraint

type IMLMultiArrayShapeConstraint interface {
	objectivec.IObject

	// Array of allowed shapes for a multiarray feature.
	EnumeratedShapes() []foundation.NSArray
	// The allowable range for a dimention of the multiarray.
	SizeRangeForDimension() []foundation.NSValue
	// The type of the shape constraint.
	Type() MLMultiArrayShapeConstraintType

	// The type for the multi array.
	DataType() MLMultiArrayDataType
	SetDataType(value MLMultiArrayDataType)
	// The shape of the multi array.
	Shape() foundation.NSNumber
	SetShape(value foundation.NSNumber)
	// The constraint on the shape of the multiarray.
	ShapeConstraint() IMLMultiArrayShapeConstraint
	SetShapeConstraint(value IMLMultiArrayShapeConstraint)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLMultiArrayShapeConstraint class.

Accessing the Constraints

  • [IMLMultiArrayShapeConstraint.EnumeratedShapes]: Array of allowed shapes for a multiarray feature.
  • [IMLMultiArrayShapeConstraint.SizeRangeForDimension]: The allowable range for a dimention of the multiarray.
  • [IMLMultiArrayShapeConstraint.Type]: The type of the shape constraint.

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayShapeConstraint

type IMLNeuralEngineComputeDevice

type IMLNeuralEngineComputeDevice interface {
	objectivec.IObject
	MLComputeDeviceProtocol

	// The total number of cores in the Neural Engine.
	TotalCoreCount() int
}

An interface definition for the MLNeuralEngineComputeDevice class.

Getting the Total Core Count

  • [IMLNeuralEngineComputeDevice.TotalCoreCount]: The total number of cores in the Neural Engine.

See: https://developer.apple.com/documentation/CoreML/MLNeuralEngineComputeDevice

type IMLNumericConstraint

type IMLNumericConstraint interface {
	objectivec.IObject

	// The smallest numerical value allowed by this constraint.
	MinNumber() foundation.NSNumber
	// The largest numerical value allowed by this constraint.
	MaxNumber() foundation.NSNumber
	// A set of the numbers allowed in this constraint.
	EnumeratedNumbers() foundation.INSSet

	// The constraints of this paramter description value, if and only if the value is numerical.
	NumericConstraint() IMLNumericConstraint
	SetNumericConstraint(value IMLNumericConstraint)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLNumericConstraint class.

Numeric Constraints

  • [IMLNumericConstraint.MinNumber]: The smallest numerical value allowed by this constraint.
  • [IMLNumericConstraint.MaxNumber]: The largest numerical value allowed by this constraint.
  • [IMLNumericConstraint.EnumeratedNumbers]: A set of the numbers allowed in this constraint.

See: https://developer.apple.com/documentation/CoreML/MLNumericConstraint

type IMLOptimizationHints

type IMLOptimizationHints interface {
	objectivec.IObject

	// The anticipated reshape frequency
	ReshapeFrequency() MLReshapeFrequencyHint
	SetReshapeFrequency(value MLReshapeFrequencyHint)

	// Optimization strategy for the model specialization.
	SpecializationStrategy() MLSpecializationStrategy
	SetSpecializationStrategy(value MLSpecializationStrategy)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLOptimizationHints class.

Getting the reshape frequency

  • [IMLOptimizationHints.ReshapeFrequency]: The anticipated reshape frequency
  • [IMLOptimizationHints.SetReshapeFrequency]

Getting the specialization strategy

  • [IMLOptimizationHints.SpecializationStrategy]: Optimization strategy for the model specialization.
  • [IMLOptimizationHints.SetSpecializationStrategy]

See: https://developer.apple.com/documentation/CoreML/MLOptimizationHints-c.class

type IMLParameterDescription

type IMLParameterDescription interface {
	objectivec.IObject

	// The default value for the parameter.
	DefaultValue() objectivec.IObject
	// The key for this parameter description value.
	Key() IMLParameterKey

	// The constraints of this paramter description value, if and only if the value is numerical.
	NumericConstraint() IMLNumericConstraint

	// A Boolean value that indicates whether you can update the model with additional training.
	IsUpdatable() bool
	SetIsUpdatable(value bool)
	// A dictionary of the descriptions for the model’s parameters.
	ParameterDescriptionsByKey() IMLParameterDescription
	SetParameterDescriptionsByKey(value IMLParameterDescription)
	// A dictionary of the training input feature descriptions, which the model keys by the input’s name.
	TrainingInputDescriptionsByName() IMLFeatureDescription
	SetTrainingInputDescriptionsByName(value IMLFeatureDescription)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLParameterDescription class.

Describing the model parameter

  • [IMLParameterDescription.DefaultValue]: The default value for the parameter.
  • [IMLParameterDescription.Key]: The key for this parameter description value.

Constraining numeric values

  • [IMLParameterDescription.NumericConstraint]: The constraints of this paramter description value, if and only if the value is numerical.

See: https://developer.apple.com/documentation/CoreML/MLParameterDescription

type IMLParameterKey

type IMLParameterKey interface {
	IMLKey

	// Creates a copy of a parameter key and adds the scope to it.
	ScopedTo(scope string) IMLParameterKey

	// The list of available compute devices that the model’s prediction methods use.
	AvailableComputeDevices() objectivec.IObject
	SetAvailableComputeDevices(value objectivec.IObject)
	// The configuration of the model set during initialization.
	Configuration() IMLModelConfiguration
	SetConfiguration(value IMLModelConfiguration)
	// Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.
	ModelDescription() IMLModelDescription
	SetModelDescription(value IMLModelDescription)
	// A dictionary of configuration settings your app can override when loading a model.
	Parameters() IMLParameterKey
	SetParameters(value IMLParameterKey)
}

An interface definition for the MLParameterKey class.

Scoping parameter keys

  • [IMLParameterKey.ScopedTo]: Creates a copy of a parameter key and adds the scope to it.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey

type IMLPredictionOptions

type IMLPredictionOptions interface {
	objectivec.IObject

	// A dictionary of feature names and client-allocated buffers.
	OutputBackings() foundation.INSDictionary
	SetOutputBackings(value foundation.INSDictionary)
}

An interface definition for the MLPredictionOptions class.

Getting features

  • [IMLPredictionOptions.OutputBackings]: A dictionary of feature names and client-allocated buffers.
  • [IMLPredictionOptions.SetOutputBackings]

See: https://developer.apple.com/documentation/CoreML/MLPredictionOptions

type IMLSequence

type IMLSequence interface {
	objectivec.IObject

	// The underlying type of the sequence’s elements.
	Type() MLFeatureType

	// An array of strings in the sequence.
	StringValues() []string
	// An array of 64-bit integers in the sequence.
	Int64Values() []foundation.NSNumber

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLSequence class.

Identifying the sequence’s element type

  • [IMLSequence.Type]: The underlying type of the sequence’s elements.

Retrieving the Sequence’s Values

  • [IMLSequence.StringValues]: An array of strings in the sequence.
  • [IMLSequence.Int64Values]: An array of 64-bit integers in the sequence.

See: https://developer.apple.com/documentation/CoreML/MLSequence

type IMLSequenceConstraint

type IMLSequenceConstraint interface {
	objectivec.IObject

	// The description that all sequence elements must match.
	ValueDescription() IMLFeatureDescription
	// The range of values allowed for the sequence’s length.
	CountRange() foundation.NSRange

	// The constraint for a dictionary feature.
	DictionaryConstraint() IMLDictionaryConstraint
	SetDictionaryConstraint(value IMLDictionaryConstraint)
	// The size and format constraints for an image feature.
	ImageConstraint() IMLImageConstraint
	SetImageConstraint(value IMLImageConstraint)
	// The constraints on a multidimensional array feature.
	MultiArrayConstraint() IMLMultiArrayConstraint
	SetMultiArrayConstraint(value IMLMultiArrayConstraint)
	// The constraints for a sequence feature.
	SequenceConstraint() IMLSequenceConstraint
	SetSequenceConstraint(value IMLSequenceConstraint)
	// The state feature value constraint.
	StateConstraint() IMLStateConstraint
	SetStateConstraint(value IMLStateConstraint)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLSequenceConstraint class.

Accessing the constraints

  • [IMLSequenceConstraint.ValueDescription]: The description that all sequence elements must match.
  • [IMLSequenceConstraint.CountRange]: The range of values allowed for the sequence’s length.

See: https://developer.apple.com/documentation/CoreML/MLSequenceConstraint

type IMLState

type IMLState interface {
	objectivec.IObject
}

An interface definition for the MLState class.

See: https://developer.apple.com/documentation/CoreML/MLState

type IMLStateConstraint

type IMLStateConstraint interface {
	objectivec.IObject

	// The shape of the state buffer.
	BufferShape() int
	SetBufferShape(value int)
	// The data type of scalars in the state buffer.
	DataType() MLMultiArrayDataType

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the MLStateConstraint class.

Inspecting a state constraint

  • [IMLStateConstraint.BufferShape]: The shape of the state buffer.
  • [IMLStateConstraint.SetBufferShape]
  • [IMLStateConstraint.DataType]: The data type of scalars in the state buffer.

See: https://developer.apple.com/documentation/CoreML/MLStateConstraint

type IMLTask

type IMLTask interface {
	objectivec.IObject

	// A unique name of the task to distinguish it from all other tasks at runtime.
	TaskIdentifier() string

	// Begins or resumes a machine learning task.
	Resume()
	// Cancels a machine learning task before it completes.
	Cancel()

	// The current state of the machine learning task.
	State() MLTaskState
	// The underlying error if the task is in a failed state.
	Error() foundation.INSError
}

An interface definition for the MLTask class.

Identifying a task

  • [IMLTask.TaskIdentifier]: A unique name of the task to distinguish it from all other tasks at runtime.

Starting and stopping a task

  • [IMLTask.Resume]: Begins or resumes a machine learning task.
  • [IMLTask.Cancel]: Cancels a machine learning task before it completes.

Checking the state of a task

  • [IMLTask.State]: The current state of the machine learning task.
  • [IMLTask.Error]: The underlying error if the task is in a failed state.

See: https://developer.apple.com/documentation/CoreML/MLTask

type IMLUpdateContext

type IMLUpdateContext interface {
	objectivec.IObject

	// The event type that triggered an update task to notify your app’s completion and update progress handlers.
	Event() MLUpdateProgressEvent
	// The update task that generated the update context.
	Task() IMLUpdateTask
	// The parameters for the update task.
	Parameters() foundation.INSDictionary

	// The training metrics of the model for the update task, contained in a dictionary.
	Metrics() foundation.INSDictionary

	// The underlying Core ML model stored in memory.
	Model() IMLModel
}

An interface definition for the MLUpdateContext class.

Getting the update context

  • [IMLUpdateContext.Event]: The event type that triggered an update task to notify your app’s completion and update progress handlers.
  • [IMLUpdateContext.Task]: The update task that generated the update context.
  • [IMLUpdateContext.Parameters]: The parameters for the update task.

Evaluating the update

  • [IMLUpdateContext.Metrics]: The training metrics of the model for the update task, contained in a dictionary.

Saving an updated model

  • [IMLUpdateContext.Model]: The underlying Core ML model stored in memory.

See: https://developer.apple.com/documentation/CoreML/MLUpdateContext

type IMLUpdateProgressHandlers

type IMLUpdateProgressHandlers interface {
	objectivec.IObject

	// Creates the collection of closures an update task uses to notify your app of its progress.
	InitForEventsProgressHandlerCompletionHandler(interestedEvents MLUpdateProgressEvent, progressHandler MLUpdateContextHandler, completionHandler MLUpdateContextHandler) MLUpdateProgressHandlers
}

An interface definition for the MLUpdateProgressHandlers class.

Creating progress handlers

  • [IMLUpdateProgressHandlers.InitForEventsProgressHandlerCompletionHandler]: Creates the collection of closures an update task uses to notify your app of its progress.

See: https://developer.apple.com/documentation/CoreML/MLUpdateProgressHandlers

type IMLUpdateTask

type IMLUpdateTask interface {
	IMLTask

	// Resumes a model update with updated parameter values.
	ResumeWithParameters(updateParameters foundation.INSDictionary)
}

An interface definition for the MLUpdateTask class.

Starting and Resuming an Update

  • [IMLUpdateTask.ResumeWithParameters]: Resumes a model update with updated parameter values.

See: https://developer.apple.com/documentation/CoreML/MLUpdateTask

type MLArrayBatchProvider

type MLArrayBatchProvider struct {
	objectivec.Object
}

A convenience wrapper for batches of feature providers.

Overview

This batch provider supports an array of feature providers or a dictionary of arrays of feature values.

Creating a batch provider

Accessing the feature providers

See: https://developer.apple.com/documentation/CoreML/MLArrayBatchProvider

func MLArrayBatchProviderFromID

func MLArrayBatchProviderFromID(id objc.ID) MLArrayBatchProvider

MLArrayBatchProviderFromID constructs a MLArrayBatchProvider from an objc.ID.

A convenience wrapper for batches of feature providers.

func NewArrayBatchProviderWithDictionaryError

func NewArrayBatchProviderWithDictionaryError(dictionary foundation.INSDictionary) (MLArrayBatchProvider, error)

Creates a batch provider based on feature names and their associated arrays of data.

dictionary: A dictionary which maps feature names to an array of values. The error case occurs when all the arrays do not have the same length or the values in an aray are not expressible as an MLFeatureValue.

Discussion

This initializer is convenient when the data are available as individual arrays.

See: https://developer.apple.com/documentation/CoreML/MLArrayBatchProvider/init(dictionary:)

func NewArrayBatchProviderWithFeatureProviderArray

func NewArrayBatchProviderWithFeatureProviderArray(array []objectivec.IObject) MLArrayBatchProvider

Creates the batch provider based on the array of feature providers.

array: The array of feature providers for the batch.

See: https://developer.apple.com/documentation/CoreML/MLArrayBatchProvider/init(array:)

func NewMLArrayBatchProvider

func NewMLArrayBatchProvider() MLArrayBatchProvider

NewMLArrayBatchProvider creates a new MLArrayBatchProvider instance.

func (MLArrayBatchProvider) Array

The array of feature providers.

See: https://developer.apple.com/documentation/CoreML/MLArrayBatchProvider/array

func (MLArrayBatchProvider) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLArrayBatchProvider) Count

func (a MLArrayBatchProvider) Count() int

The number of feature providers in this batch.

See: https://developer.apple.com/documentation/CoreML/MLBatchProvider/count

func (MLArrayBatchProvider) FeaturesAtIndex

func (a MLArrayBatchProvider) FeaturesAtIndex(index int) MLFeatureProvider

Returns the feature provider at the given index.

index: The index of the desired feature provider.

Return Value

The feature provider at the given index.

See: https://developer.apple.com/documentation/CoreML/MLBatchProvider/features(at:)

func (MLArrayBatchProvider) Init

Init initializes the instance.

func (MLArrayBatchProvider) InitWithDictionaryError

func (a MLArrayBatchProvider) InitWithDictionaryError(dictionary foundation.INSDictionary) (MLArrayBatchProvider, error)

Creates a batch provider based on feature names and their associated arrays of data.

dictionary: A dictionary which maps feature names to an array of values. The error case occurs when all the arrays do not have the same length or the values in an aray are not expressible as an MLFeatureValue.

Discussion

This initializer is convenient when the data are available as individual arrays.

See: https://developer.apple.com/documentation/CoreML/MLArrayBatchProvider/init(dictionary:)

func (MLArrayBatchProvider) InitWithFeatureProviderArray

func (a MLArrayBatchProvider) InitWithFeatureProviderArray(array []objectivec.IObject) MLArrayBatchProvider

Creates the batch provider based on the array of feature providers.

array: The array of feature providers for the batch.

See: https://developer.apple.com/documentation/CoreML/MLArrayBatchProvider/init(array:)

type MLArrayBatchProviderClass

type MLArrayBatchProviderClass struct {
	// contains filtered or unexported fields
}

func GetMLArrayBatchProviderClass

func GetMLArrayBatchProviderClass() MLArrayBatchProviderClass

GetMLArrayBatchProviderClass returns the class object for MLArrayBatchProvider.

func (MLArrayBatchProviderClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLBatchProvider

type MLBatchProvider interface {
	objectivec.IObject

	// Returns the feature provider at the given index.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLBatchProvider/features(at:)
	FeaturesAtIndex(index int) MLFeatureProvider

	// The number of feature providers in this batch.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLBatchProvider/count
	Count() int
}

An interface that represents a collection of feature providers.

See: https://developer.apple.com/documentation/CoreML/MLBatchProvider

type MLBatchProviderObject

type MLBatchProviderObject struct {
	objectivec.Object
}

MLBatchProviderObject wraps an existing Objective-C object that conforms to the MLBatchProvider protocol.

func MLBatchProviderObjectFromID

func MLBatchProviderObjectFromID(id objc.ID) MLBatchProviderObject

MLBatchProviderObjectFromID constructs a MLBatchProviderObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (MLBatchProviderObject) BaseObject

func (o MLBatchProviderObject) BaseObject() objectivec.Object

func (MLBatchProviderObject) Count

func (o MLBatchProviderObject) Count() int

The number of feature providers in this batch.

See: https://developer.apple.com/documentation/CoreML/MLBatchProvider/count

func (MLBatchProviderObject) FeaturesAtIndex

func (o MLBatchProviderObject) FeaturesAtIndex(index int) MLFeatureProvider

Returns the feature provider at the given index.

index: The index of the desired feature provider.

Return Value

The feature provider at the given index.

See: https://developer.apple.com/documentation/CoreML/MLBatchProvider/features(at:)

type MLCPUComputeDevice

type MLCPUComputeDevice struct {
	objectivec.Object
}

An object that represents a CPU compute device.

See: https://developer.apple.com/documentation/CoreML/MLCPUComputeDevice

func MLCPUComputeDeviceFromID

func MLCPUComputeDeviceFromID(id objc.ID) MLCPUComputeDevice

MLCPUComputeDeviceFromID constructs a MLCPUComputeDevice from an objc.ID.

An object that represents a CPU compute device.

func NewMLCPUComputeDevice

func NewMLCPUComputeDevice() MLCPUComputeDevice

NewMLCPUComputeDevice creates a new MLCPUComputeDevice instance.

func (MLCPUComputeDevice) Autorelease

func (c MLCPUComputeDevice) Autorelease() MLCPUComputeDevice

Autorelease adds the receiver to the current autorelease pool.

func (MLCPUComputeDevice) Init

Init initializes the instance.

type MLCPUComputeDeviceClass

type MLCPUComputeDeviceClass struct {
	// contains filtered or unexported fields
}

func GetMLCPUComputeDeviceClass

func GetMLCPUComputeDeviceClass() MLCPUComputeDeviceClass

GetMLCPUComputeDeviceClass returns the class object for MLCPUComputeDevice.

func (MLCPUComputeDeviceClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLComputeDeviceProtocol

type MLComputeDeviceProtocol interface {
	objectivec.IObject
}

An interface that represents a compute device type.

See: https://developer.apple.com/documentation/CoreML/MLComputeDeviceProtocol

type MLComputeDeviceProtocolObject

type MLComputeDeviceProtocolObject struct {
	objectivec.Object
}

MLComputeDeviceProtocolObject wraps an existing Objective-C object that conforms to the MLComputeDeviceProtocol protocol.

func MLAllComputeDevices

func MLAllComputeDevices() []MLComputeDeviceProtocolObject

MLAllComputeDevices returns an array that contains all of the compute devices that are accessible.

See: https://developer.apple.com/documentation/CoreML/MLAllComputeDevices

func MLComputeDeviceProtocolObjectFromID

func MLComputeDeviceProtocolObjectFromID(id objc.ID) MLComputeDeviceProtocolObject

MLComputeDeviceProtocolObjectFromID constructs a MLComputeDeviceProtocolObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (MLComputeDeviceProtocolObject) BaseObject

type MLComputePlan

type MLComputePlan struct {
	objectivec.Object
}

A class describing the plan for executing a model.

Overview

The application can use the plan to estimate the necessary cost and resources of the model before running the predictions.

Getting the model structure

Getting the device usage

Getting the estimated cost

See: https://developer.apple.com/documentation/CoreML/MLComputePlan-85vdw

func MLComputePlanFromID

func MLComputePlanFromID(id objc.ID) MLComputePlan

MLComputePlanFromID constructs a MLComputePlan from an objc.ID.

A class describing the plan for executing a model.

func NewMLComputePlan

func NewMLComputePlan() MLComputePlan

NewMLComputePlan creates a new MLComputePlan instance.

func (MLComputePlan) Autorelease

func (c MLComputePlan) Autorelease() MLComputePlan

Autorelease adds the receiver to the current autorelease pool.

func (MLComputePlan) ComputeDeviceUsageForMLProgramOperation

func (c MLComputePlan) ComputeDeviceUsageForMLProgramOperation(operation IMLModelStructureProgramOperation) IMLComputePlanDeviceUsage

Returns The anticipated compute devices that would be used for executing an ML Program operation.

operation: An ML Program operation.

Return Value

The anticipated compute devices that would be used for executing the operation or `nil`if the usage couldn’t be determined.

See: https://developer.apple.com/documentation/CoreML/MLComputePlan-85vdw/computeDeviceUsageForMLProgramOperation:

func (MLComputePlan) ComputeDeviceUsageForNeuralNetworkLayer

func (c MLComputePlan) ComputeDeviceUsageForNeuralNetworkLayer(layer IMLModelStructureNeuralNetworkLayer) IMLComputePlanDeviceUsage

Returns the anticipated compute devices that would be used for executing a NeuralNetwork layer.

layer: A NeuralNetwork layer.

Return Value

The anticipated compute devices that would be used for executing the layer or `nil` if the usage couldn’t be determined.

See: https://developer.apple.com/documentation/CoreML/MLComputePlan-85vdw/computeDeviceUsageForNeuralNetworkLayer:

func (MLComputePlan) EstimatedCostOfMLProgramOperation

func (c MLComputePlan) EstimatedCostOfMLProgramOperation(operation IMLModelStructureProgramOperation) IMLComputePlanCost

Returns the estimated cost of executing an ML Program operation.

operation: An ML Program operation.

Return Value

The estimated cost of executing the operation or nil if the cost couldn’t be estimated.

See: https://developer.apple.com/documentation/CoreML/MLComputePlan-85vdw/estimatedCostOfMLProgramOperation:

func (MLComputePlan) Init

func (c MLComputePlan) Init() MLComputePlan

Init initializes the instance.

type MLComputePlanClass

type MLComputePlanClass struct {
	// contains filtered or unexported fields
}

func GetMLComputePlanClass

func GetMLComputePlanClass() MLComputePlanClass

GetMLComputePlanClass returns the class object for MLComputePlan.

func (MLComputePlanClass) Alloc

func (mc MLComputePlanClass) Alloc() MLComputePlan

Alloc allocates memory for a new instance of the class.

func (MLComputePlanClass) LoadContentsOfURLConfiguration

func (cc MLComputePlanClass) LoadContentsOfURLConfiguration(ctx context.Context, url foundation.INSURL, configuration IMLModelConfiguration) (*MLComputePlan, error)

LoadContentsOfURLConfiguration is a synchronous wrapper around [MLComputePlan.LoadContentsOfURLConfigurationCompletionHandler]. It blocks until the completion handler fires or the context is cancelled.

func (MLComputePlanClass) LoadContentsOfURLConfigurationCompletionHandler

func (_MLComputePlanClass MLComputePlanClass) LoadContentsOfURLConfigurationCompletionHandler(url foundation.INSURL, configuration IMLModelConfiguration, handler MLComputePlanErrorHandler)

Construct the compute plan of a model asynchronously given the location of its on-disk representation.

url: The location of its on-disk representation (.mlmodelc directory).

configuration: The model configuration.

handler: When the compute plan is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLComputePlan instance or NSError object.

See: https://developer.apple.com/documentation/CoreML/MLComputePlan-85vdw/loadContentsOfURL:configuration:completionHandler:

func (MLComputePlanClass) LoadModelAssetConfiguration

func (cc MLComputePlanClass) LoadModelAssetConfiguration(ctx context.Context, asset IMLModelAsset, configuration IMLModelConfiguration) (*MLComputePlan, error)

LoadModelAssetConfiguration is a synchronous wrapper around [MLComputePlan.LoadModelAssetConfigurationCompletionHandler]. It blocks until the completion handler fires or the context is cancelled.

func (MLComputePlanClass) LoadModelAssetConfigurationCompletionHandler

func (_MLComputePlanClass MLComputePlanClass) LoadModelAssetConfigurationCompletionHandler(asset IMLModelAsset, configuration IMLModelConfiguration, handler MLComputePlanErrorHandler)

Construct the compute plan of a model asynchronously given the model asset.

asset: The model asset.

configuration: The model configuration.

handler: When the compute plan is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLComputePlan instance or NSError object.

See: https://developer.apple.com/documentation/CoreML/MLComputePlan-85vdw/loadModelAsset:configuration:completionHandler:

type MLComputePlanCost

type MLComputePlanCost struct {
	objectivec.Object
}

A class that represents the estimated cost of executing a layer or operation.

Accessing the weight

  • MLComputePlanCost.Weight: The estimated workload of executing the operation over the total model execution. The value is between [0.0, 1.0].

See: https://developer.apple.com/documentation/CoreML/MLComputePlanCost

func MLComputePlanCostFromID

func MLComputePlanCostFromID(id objc.ID) MLComputePlanCost

MLComputePlanCostFromID constructs a MLComputePlanCost from an objc.ID.

A class that represents the estimated cost of executing a layer or operation.

func NewMLComputePlanCost

func NewMLComputePlanCost() MLComputePlanCost

NewMLComputePlanCost creates a new MLComputePlanCost instance.

func (MLComputePlanCost) Autorelease

func (c MLComputePlanCost) Autorelease() MLComputePlanCost

Autorelease adds the receiver to the current autorelease pool.

func (MLComputePlanCost) Init

Init initializes the instance.

func (MLComputePlanCost) Weight

func (c MLComputePlanCost) Weight() float64

The estimated workload of executing the operation over the total model execution. The value is between [0.0, 1.0].

See: https://developer.apple.com/documentation/CoreML/MLComputePlanCost/weight

type MLComputePlanCostClass

type MLComputePlanCostClass struct {
	// contains filtered or unexported fields
}

func GetMLComputePlanCostClass

func GetMLComputePlanCostClass() MLComputePlanCostClass

GetMLComputePlanCostClass returns the class object for MLComputePlanCost.

func (MLComputePlanCostClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLComputePlanDeviceUsage

type MLComputePlanDeviceUsage struct {
	objectivec.Object
}

The anticipated compute devices to use for executing a layer or operation.

Getting the compute device

See: https://developer.apple.com/documentation/CoreML/MLComputePlanDeviceUsage

func MLComputePlanDeviceUsageFromID

func MLComputePlanDeviceUsageFromID(id objc.ID) MLComputePlanDeviceUsage

MLComputePlanDeviceUsageFromID constructs a MLComputePlanDeviceUsage from an objc.ID.

The anticipated compute devices to use for executing a layer or operation.

func NewMLComputePlanDeviceUsage

func NewMLComputePlanDeviceUsage() MLComputePlanDeviceUsage

NewMLComputePlanDeviceUsage creates a new MLComputePlanDeviceUsage instance.

func (MLComputePlanDeviceUsage) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLComputePlanDeviceUsage) Init

Init initializes the instance.

func (MLComputePlanDeviceUsage) PreferredComputeDevice

func (c MLComputePlanDeviceUsage) PreferredComputeDevice() MLComputeDeviceProtocol

The compute device that the framework prefers to execute the layer/operation.

See: https://developer.apple.com/documentation/CoreML/MLComputePlanDeviceUsage/preferredComputeDevice

func (MLComputePlanDeviceUsage) SupportedComputeDevices

func (c MLComputePlanDeviceUsage) SupportedComputeDevices() []objectivec.IObject

The compute devices that can execute the layer/operation.

See: https://developer.apple.com/documentation/CoreML/MLComputePlanDeviceUsage/supportedComputeDevices

type MLComputePlanDeviceUsageClass

type MLComputePlanDeviceUsageClass struct {
	// contains filtered or unexported fields
}

func GetMLComputePlanDeviceUsageClass

func GetMLComputePlanDeviceUsageClass() MLComputePlanDeviceUsageClass

GetMLComputePlanDeviceUsageClass returns the class object for MLComputePlanDeviceUsage.

func (MLComputePlanDeviceUsageClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLComputePlanErrorHandler

type MLComputePlanErrorHandler = func(*MLComputePlan, error)

MLComputePlanErrorHandler handles When the compute plan is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLComputePlan instance or NSError object. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

  • [MLComputePlan.LoadContentsOfURLConfigurationCompletionHandler]
  • [MLComputePlan.LoadModelAssetConfigurationCompletionHandler]

type MLComputeUnits

type MLComputeUnits int

See: https://developer.apple.com/documentation/CoreML/MLComputeUnits

const (
	// MLComputeUnitsAll: The option you choose to allow the model to use all compute units available, including the neural engine.
	MLComputeUnitsAll MLComputeUnits = 2
	// MLComputeUnitsCPUAndGPU: The option you choose to allow the model to use both the CPU and GPU, but not the neural engine.
	MLComputeUnitsCPUAndGPU MLComputeUnits = 1
	// MLComputeUnitsCPUAndNeuralEngine: The option you choose to allow the model to use both the CPU and neural engine, but not the GPU.
	MLComputeUnitsCPUAndNeuralEngine MLComputeUnits = 3
	// MLComputeUnitsCPUOnly: The option you choose to limit the model to only use the CPU.
	MLComputeUnitsCPUOnly MLComputeUnits = 0
)

func (MLComputeUnits) String

func (e MLComputeUnits) String() string

type MLCustomLayer

type MLCustomLayer interface {
	objectivec.IObject

	// Assigns the weights for the connections within the layer.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLCustomLayer/setWeightData(_:)
	SetWeightDataError(weights []foundation.NSData) (bool, error)

	// Calculates the shapes of the output of this layer for the given input shapes.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLCustomLayer/outputShapes(forInputShapes:)
	OutputShapesForInputShapesError(inputShapes []foundation.NSArray) ([]foundation.NSArray, error)

	// Evaluates the custom layer with the given inputs.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLCustomLayer/evaluate(inputs:outputs:)
	EvaluateOnCPUWithInputsOutputsError(inputs []MLMultiArray, outputs []MLMultiArray) (bool, error)
}

An interface that defines the behavior of a custom layer in your neural network model.

See: https://developer.apple.com/documentation/CoreML/MLCustomLayer

type MLCustomLayerObject

type MLCustomLayerObject struct {
	objectivec.Object
}

MLCustomLayerObject wraps an existing Objective-C object that conforms to the MLCustomLayer protocol.

func MLCustomLayerObjectFromID

func MLCustomLayerObjectFromID(id objc.ID) MLCustomLayerObject

MLCustomLayerObjectFromID constructs a MLCustomLayerObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (MLCustomLayerObject) BaseObject

func (o MLCustomLayerObject) BaseObject() objectivec.Object

func (MLCustomLayerObject) EncodeToCommandBufferInputsOutputsError

func (o MLCustomLayerObject) EncodeToCommandBufferInputsOutputsError(commandBuffer metal.MTLCommandBuffer, inputs []objectivec.IObject, outputs []objectivec.IObject) (bool, error)

Encodes GPU commands to evaluate the custom layer.

commandBuffer: A command buffer that defines the work the layer performs on the GPU.

inputs: A texture array that represents the layer’s inputs.

outputs: A texture array that represents the layer’s outputs.

Discussion

Implement this method to use the GPU to evaluate your layer. Fill `commandBuffer` with the GPU commands that evaluate the layer. Don’t commit the command buffer in this method; Core ML executes the command buffer after this method returns.

Improve your layer’s performance by caching the MTLComputePipelineState instances you create and intend to reuse in subsequent calls.

Implementing this method doesn’t guarantee that Core ML evaluates this layer on the GPU. For example, Core ML may evaluate the layer on the CPU if the system doesn’t have enough GPU’s resources to run the custom layer.

If you don’t implement this method, Core ML instead uses [EvaluateOnCPUWithInputsOutputsError].

For more information about using the GPU for general purpose programming, see `Compute Processing`.

See: https://developer.apple.com/documentation/CoreML/MLCustomLayer/encode(commandBuffer:inputs:outputs:)

func (MLCustomLayerObject) EvaluateOnCPUWithInputsOutputsError

func (o MLCustomLayerObject) EvaluateOnCPUWithInputsOutputsError(inputs []MLMultiArray, outputs []MLMultiArray) (bool, error)

Evaluates the custom layer with the given inputs.

inputs: The array of inputs to be evaluated.

outputs: The array of outputs to be populated by evaluating the given inputs.

Discussion

Implement this method to evaluate the inputs using your layer’s custom behavior and to populate the output arrays. It will be called for each evaluation of your model performed on the CPU.

The memory for both input and output arrays is preallocated; don’t copy or move it. The inputs and outputs will have the shapes of the most recent call to [OutputShapesForInputShapesError]. Don’t modify the input values.

Investigate vecLib for methods that could optimize your implementation significantly.

See: https://developer.apple.com/documentation/CoreML/MLCustomLayer/evaluate(inputs:outputs:)

func (MLCustomLayerObject) OutputShapesForInputShapesError

func (o MLCustomLayerObject) OutputShapesForInputShapesError(inputShapes []foundation.NSArray) ([]foundation.NSArray, error)

Calculates the shapes of the output of this layer for the given input shapes.

inputShapes: The shapes of the input for this layer.

Return Value

The shapes of the output for the given input shapes.

Discussion

Implement this method to define the layer’s interface with the rest of the network. It will be called at least once at load time and any time the size of the inputs changes in a call to prediction(from:).

This method consumes and returns arrays of shapes, for inputs and outputs of the custom layer, respectively. See the Core ML Neural Network specification for more details about shapes and how layers use them.

See: https://developer.apple.com/documentation/CoreML/MLCustomLayer/outputShapes(forInputShapes:)

func (MLCustomLayerObject) SetWeightDataError

func (o MLCustomLayerObject) SetWeightDataError(weights []foundation.NSData) (bool, error)

Assigns the weights for the connections within the layer.

weights: The data encoded in the `weights` field of the model specification.

Discussion

Implement this method to assign the weights for all the connections between nodes in your layer. This method is called once after the initialization call. Your implementation should validate the weights and throw an error if the weights do not have the expected shape or values.

The data encoded in the `weights` field of the `XCUIElementTypeMlmodel` file is loaded and passed into this method. If there are repeated weights in the `XCUIElementTypeMlmodel` file, they will be listed explicitly in the `weights` array. The weight values are provided in the order that they were defined during the custom layer conversion process. Keep a reference to the `weights` passed in because copying the `weights` array can significantly increase an app’s memory. Avoid modifying values of the weights.

See: https://developer.apple.com/documentation/CoreML/MLCustomLayer/setWeightData(_:)

type MLCustomModel

type MLCustomModel interface {
	objectivec.IObject

	// Predicts output values from the given input features.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLCustomModel/prediction(from:options:)
	PredictionFromFeaturesOptionsError(input MLFeatureProvider, options IMLPredictionOptions) (MLFeatureProvider, error)
}

An interface that defines the behavior of a custom model.

See: https://developer.apple.com/documentation/CoreML/MLCustomModel

type MLCustomModelObject

type MLCustomModelObject struct {
	objectivec.Object
}

MLCustomModelObject wraps an existing Objective-C object that conforms to the MLCustomModel protocol.

func MLCustomModelObjectFromID

func MLCustomModelObjectFromID(id objc.ID) MLCustomModelObject

MLCustomModelObjectFromID constructs a MLCustomModelObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (MLCustomModelObject) BaseObject

func (o MLCustomModelObject) BaseObject() objectivec.Object

func (MLCustomModelObject) PredictionFromFeaturesOptionsError

func (o MLCustomModelObject) PredictionFromFeaturesOptionsError(input MLFeatureProvider, options IMLPredictionOptions) (MLFeatureProvider, error)

Predicts output values from the given input features.

input: The feature values the models needs to make its prediction.

options: The options to be applied to the prediction.

Return Value

A feature provider that represents the model’s prediction.

See: https://developer.apple.com/documentation/CoreML/MLCustomModel/prediction(from:options:)

func (MLCustomModelObject) PredictionsFromBatchOptionsError

func (o MLCustomModelObject) PredictionsFromBatchOptionsError(inputBatch MLBatchProvider, options IMLPredictionOptions) (MLBatchProvider, error)

Predicts output values from the given batch of input features.

inputBatch: The batch of feature values the model needs to make its predictions.

options: The options to be applied to the predictions.

Return Value

A batch provider that represents the model’s predictions for the batch of inputs.

See: https://developer.apple.com/documentation/CoreML/MLCustomModel/predictions(from:options:)

type MLDictionaryConstraint

type MLDictionaryConstraint struct {
	objectivec.Object
}

The constraint on the keys for a dictionary feature.

Accessing the constraint

See: https://developer.apple.com/documentation/CoreML/MLDictionaryConstraint

func MLDictionaryConstraintFromID

func MLDictionaryConstraintFromID(id objc.ID) MLDictionaryConstraint

MLDictionaryConstraintFromID constructs a MLDictionaryConstraint from an objc.ID.

The constraint on the keys for a dictionary feature.

func NewMLDictionaryConstraint

func NewMLDictionaryConstraint() MLDictionaryConstraint

NewMLDictionaryConstraint creates a new MLDictionaryConstraint instance.

func (MLDictionaryConstraint) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLDictionaryConstraint) DictionaryConstraint

func (d MLDictionaryConstraint) DictionaryConstraint() IMLDictionaryConstraint

The constraint for a dictionary feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/dictionaryconstraint

func (MLDictionaryConstraint) EncodeWithCoder

func (d MLDictionaryConstraint) EncodeWithCoder(coder foundation.INSCoder)

func (MLDictionaryConstraint) ImageConstraint

func (d MLDictionaryConstraint) ImageConstraint() IMLImageConstraint

The size and format constraints for an image feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/imageconstraint

func (MLDictionaryConstraint) Init

Init initializes the instance.

func (MLDictionaryConstraint) KeyType

The key type for the dictionary.

See: https://developer.apple.com/documentation/CoreML/MLDictionaryConstraint/keyType

func (MLDictionaryConstraint) MultiArrayConstraint

func (d MLDictionaryConstraint) MultiArrayConstraint() IMLMultiArrayConstraint

The constraints on a multidimensional array feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/multiarrayconstraint

func (MLDictionaryConstraint) SequenceConstraint

func (d MLDictionaryConstraint) SequenceConstraint() IMLSequenceConstraint

The constraints for a sequence feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/sequenceconstraint

func (MLDictionaryConstraint) SetDictionaryConstraint

func (d MLDictionaryConstraint) SetDictionaryConstraint(value IMLDictionaryConstraint)

func (MLDictionaryConstraint) SetImageConstraint

func (d MLDictionaryConstraint) SetImageConstraint(value IMLImageConstraint)

func (MLDictionaryConstraint) SetMultiArrayConstraint

func (d MLDictionaryConstraint) SetMultiArrayConstraint(value IMLMultiArrayConstraint)

func (MLDictionaryConstraint) SetSequenceConstraint

func (d MLDictionaryConstraint) SetSequenceConstraint(value IMLSequenceConstraint)

func (MLDictionaryConstraint) SetStateConstraint

func (d MLDictionaryConstraint) SetStateConstraint(value IMLStateConstraint)

func (MLDictionaryConstraint) StateConstraint

func (d MLDictionaryConstraint) StateConstraint() IMLStateConstraint

The state feature value constraint.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/stateconstraint

type MLDictionaryConstraintClass

type MLDictionaryConstraintClass struct {
	// contains filtered or unexported fields
}

func GetMLDictionaryConstraintClass

func GetMLDictionaryConstraintClass() MLDictionaryConstraintClass

GetMLDictionaryConstraintClass returns the class object for MLDictionaryConstraint.

func (MLDictionaryConstraintClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLDictionaryFeatureProvider

type MLDictionaryFeatureProvider struct {
	objectivec.Object
}

A convenience wrapper for the given dictionary of data.

Overview

If your input data is stored in a dictionary, consider this type of MLFeatureProvider that is backed by a dictionary. It is a convenience interface, saving you the trouble of iterating through the dictionary to assign all of its values.

Creating the provider

Accessing the features

See: https://developer.apple.com/documentation/CoreML/MLDictionaryFeatureProvider

func MLDictionaryFeatureProviderFromID

func MLDictionaryFeatureProviderFromID(id objc.ID) MLDictionaryFeatureProvider

MLDictionaryFeatureProviderFromID constructs a MLDictionaryFeatureProvider from an objc.ID.

A convenience wrapper for the given dictionary of data.

func NewDictionaryFeatureProviderWithDictionaryError

func NewDictionaryFeatureProviderWithDictionaryError(dictionary foundation.INSDictionary) (MLDictionaryFeatureProvider, error)

Creates the feature provider based on a dictionary.

dictionary: The dictionary of feature names and feature values.

See: https://developer.apple.com/documentation/CoreML/MLDictionaryFeatureProvider/init(dictionary:)

func NewMLDictionaryFeatureProvider

func NewMLDictionaryFeatureProvider() MLDictionaryFeatureProvider

NewMLDictionaryFeatureProvider creates a new MLDictionaryFeatureProvider instance.

func (MLDictionaryFeatureProvider) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLDictionaryFeatureProvider) EncodeWithCoder

func (d MLDictionaryFeatureProvider) EncodeWithCoder(coder foundation.INSCoder)

func (MLDictionaryFeatureProvider) FeatureNames

The set of valid feature names.

See: https://developer.apple.com/documentation/CoreML/MLFeatureProvider/featureNames

func (MLDictionaryFeatureProvider) FeatureValueForName

func (d MLDictionaryFeatureProvider) FeatureValueForName(featureName string) IMLFeatureValue

Accesses the feature value given the feature’s name.

featureName: The name of the feature of the desired value.

Return Value

The value of the feature, or nil if no value exists for that name.

See: https://developer.apple.com/documentation/CoreML/MLFeatureProvider/featureValue(for:)

func (MLDictionaryFeatureProvider) Init

Init initializes the instance.

func (MLDictionaryFeatureProvider) InitWithDictionaryError

Creates the feature provider based on a dictionary.

dictionary: The dictionary of feature names and feature values.

See: https://developer.apple.com/documentation/CoreML/MLDictionaryFeatureProvider/init(dictionary:)

func (MLDictionaryFeatureProvider) ObjectForKeyedSubscript

func (d MLDictionaryFeatureProvider) ObjectForKeyedSubscript(featureName string) IMLFeatureValue

Subscript interface for the feature provider to pass through to the dictionary.

See: https://developer.apple.com/documentation/CoreML/MLDictionaryFeatureProvider/subscript(_:)

type MLDictionaryFeatureProviderClass

type MLDictionaryFeatureProviderClass struct {
	// contains filtered or unexported fields
}

func GetMLDictionaryFeatureProviderClass

func GetMLDictionaryFeatureProviderClass() MLDictionaryFeatureProviderClass

GetMLDictionaryFeatureProviderClass returns the class object for MLDictionaryFeatureProvider.

func (MLDictionaryFeatureProviderClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLFeatureDescription

type MLFeatureDescription struct {
	objectivec.Object
}

The name, type, and constraints of an input or output feature.

Overview

In Core ML, a is a single input or output of a model. A model can have any number of or . Each feature has a name and a value type, which are defined in the feature’s MLFeatureDescription. Model authors use feature descriptions to help developers integrate their model properly. Each MLFeatureDescription instance has read-only properties that indicate the feature’s name, its type, and whether it’s optional.

For examples of features, see Integrating a Core ML Model into Your App. Note the three input features named `solarPanels`, `greenhouses`, and `size`, and the output feature is named `price`. All four features are of type [Double].

An MLFeatureDescription may also include constraints, which specify the limitations of the model’s input and output features. For each input feature, the constraints describe what values the model expects from your app. For each output feature, the constraints describe what values your app should expect from the model. You can also write code to inspect these descriptions before using the model in your app.

Inspecting a feature

Checking for validity

Accessing feature constraints

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription

func MLFeatureDescriptionFromID

func MLFeatureDescriptionFromID(id objc.ID) MLFeatureDescription

MLFeatureDescriptionFromID constructs a MLFeatureDescription from an objc.ID.

The name, type, and constraints of an input or output feature.

func NewMLFeatureDescription

func NewMLFeatureDescription() MLFeatureDescription

NewMLFeatureDescription creates a new MLFeatureDescription instance.

func (MLFeatureDescription) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLFeatureDescription) DictionaryConstraint

func (f MLFeatureDescription) DictionaryConstraint() IMLDictionaryConstraint

The constraint for a dictionary feature.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription/dictionaryConstraint

func (MLFeatureDescription) EncodeWithCoder

func (f MLFeatureDescription) EncodeWithCoder(coder foundation.INSCoder)

func (MLFeatureDescription) ImageConstraint

func (f MLFeatureDescription) ImageConstraint() IMLImageConstraint

The size and format constraints for an image feature.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription/imageConstraint

func (MLFeatureDescription) Init

Init initializes the instance.

func (MLFeatureDescription) InputDescriptionsByName

func (f MLFeatureDescription) InputDescriptionsByName() IMLFeatureDescription

A dictionary of input feature descriptions, which the model keys by the input’s name.

See: https://developer.apple.com/documentation/coreml/mlmodeldescription/inputdescriptionsbyname

func (MLFeatureDescription) IsAllowedValue

func (f MLFeatureDescription) IsAllowedValue(value IMLFeatureValue) bool

Checks whether the model will accept an input feature value.

value: Given the MLFeatureValue, is it compatible with the MLFeatureType of this MLFeatureDescription.

Return Value

[True] if the given MLFeatureValue is acceptable to the model’s input feature, `false` otherwise.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription/isAllowedValue(_:)

func (MLFeatureDescription) MultiArrayConstraint

func (f MLFeatureDescription) MultiArrayConstraint() IMLMultiArrayConstraint

The constraints on a multidimensional array feature.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription/multiArrayConstraint

func (MLFeatureDescription) Name

func (f MLFeatureDescription) Name() string

The name of this feature.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription/name

func (MLFeatureDescription) Optional

func (f MLFeatureDescription) Optional() bool

A Boolean value that indicates whether this feature is optional.

Discussion

Optional values can be `nil`, for models that have inputs related to features being present or not.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription/isOptional

func (MLFeatureDescription) OutputDescriptionsByName

func (f MLFeatureDescription) OutputDescriptionsByName() IMLFeatureDescription

A dictionary of output feature descriptions, which the model keys by the output’s name.

See: https://developer.apple.com/documentation/coreml/mlmodeldescription/outputdescriptionsbyname

func (MLFeatureDescription) SequenceConstraint

func (f MLFeatureDescription) SequenceConstraint() IMLSequenceConstraint

The constraints for a sequence feature.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription/sequenceConstraint

func (MLFeatureDescription) SetInputDescriptionsByName

func (f MLFeatureDescription) SetInputDescriptionsByName(value IMLFeatureDescription)

func (MLFeatureDescription) SetOutputDescriptionsByName

func (f MLFeatureDescription) SetOutputDescriptionsByName(value IMLFeatureDescription)

func (MLFeatureDescription) SetStateDescriptionsByName

func (f MLFeatureDescription) SetStateDescriptionsByName(value IMLFeatureDescription)

func (MLFeatureDescription) StateConstraint

func (f MLFeatureDescription) StateConstraint() IMLStateConstraint

The state feature value constraint.

Discussion

The property has a value when `XCUIElementTypeType == MLFeatureTypeState`.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription/stateConstraint

func (MLFeatureDescription) StateDescriptionsByName

func (f MLFeatureDescription) StateDescriptionsByName() IMLFeatureDescription

Description of the state features.

See: https://developer.apple.com/documentation/coreml/mlmodeldescription/statedescriptionsbyname

func (MLFeatureDescription) Type

The type of this feature.

See: https://developer.apple.com/documentation/CoreML/MLFeatureDescription/type

type MLFeatureDescriptionClass

type MLFeatureDescriptionClass struct {
	// contains filtered or unexported fields
}

func GetMLFeatureDescriptionClass

func GetMLFeatureDescriptionClass() MLFeatureDescriptionClass

GetMLFeatureDescriptionClass returns the class object for MLFeatureDescription.

func (MLFeatureDescriptionClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLFeatureProvider

type MLFeatureProvider interface {
	objectivec.IObject

	// Accesses the feature value given the feature’s name.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLFeatureProvider/featureValue(for:)
	FeatureValueForName(featureName string) IMLFeatureValue

	// The set of valid feature names.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLFeatureProvider/featureNames
	FeatureNames() foundation.INSSet
}

An interface that represents a collection of values for either a model’s input or its output.

See: https://developer.apple.com/documentation/CoreML/MLFeatureProvider

type MLFeatureProviderObject

type MLFeatureProviderObject struct {
	objectivec.Object
}

MLFeatureProviderObject wraps an existing Objective-C object that conforms to the MLFeatureProvider protocol.

func MLFeatureProviderObjectFromID

func MLFeatureProviderObjectFromID(id objc.ID) MLFeatureProviderObject

MLFeatureProviderObjectFromID constructs a MLFeatureProviderObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (MLFeatureProviderObject) BaseObject

func (o MLFeatureProviderObject) BaseObject() objectivec.Object

func (MLFeatureProviderObject) FeatureNames

func (o MLFeatureProviderObject) FeatureNames() foundation.INSSet

The set of valid feature names.

See: https://developer.apple.com/documentation/CoreML/MLFeatureProvider/featureNames

func (MLFeatureProviderObject) FeatureValueForName

func (o MLFeatureProviderObject) FeatureValueForName(featureName string) IMLFeatureValue

Accesses the feature value given the feature’s name.

featureName: The name of the feature of the desired value.

Return Value

The value of the feature, or nil if no value exists for that name.

See: https://developer.apple.com/documentation/CoreML/MLFeatureProvider/featureValue(for:)

type MLFeatureType

type MLFeatureType int

See: https://developer.apple.com/documentation/CoreML/MLFeatureType

const (
	// MLFeatureTypeDictionary: The type for dictionary features and feature values.
	MLFeatureTypeDictionary MLFeatureType = 6
	// MLFeatureTypeDouble: The type for double features and feature values.
	MLFeatureTypeDouble MLFeatureType = 2
	// MLFeatureTypeImage: The type for image features and feature values.
	MLFeatureTypeImage MLFeatureType = 4
	// MLFeatureTypeInt64: The type for integer features and feature values.
	MLFeatureTypeInt64 MLFeatureType = 1
	// MLFeatureTypeInvalid: The type for invalid feature values.
	MLFeatureTypeInvalid MLFeatureType = 0
	// MLFeatureTypeMultiArray: The type for multidimensional array features and feature values.
	MLFeatureTypeMultiArray MLFeatureType = 5
	// MLFeatureTypeSequence: The type for sequence features and feature values.
	MLFeatureTypeSequence MLFeatureType = 7
	// MLFeatureTypeState: MLState.
	MLFeatureTypeState MLFeatureType = 8
	// MLFeatureTypeString: The type for string features and feature values.
	MLFeatureTypeString MLFeatureType = 3
)

func (MLFeatureType) String

func (e MLFeatureType) String() string

type MLFeatureValue

type MLFeatureValue struct {
	objectivec.Object
}

A generic wrapper around an underlying value and the value’s type.

Overview

A Core ML wraps an underlying value and bundles it with that value’s type, which is one of the types that MLFeatureType defines. Apps typically access feature values indirectly by using the methods in the wrapper class Xcode automatically generates for Core ML model files.

If your app accesses an MLModel directly, it must create and consume MLFeatureProvider instances. For each prediction, Core ML accepts a feature provider for its inputs, and generates a separate feature provider for its outputs. The input feature provider contains one MLFeatureValue instance per input, and the output feature provider contains one per output. See MLFeatureDescription for more information about the model input and output features.

Accessing the feature’s type

Accessing the feature’s value

Comparing feature values

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue

func MLFeatureValueFromID

func MLFeatureValueFromID(id objc.ID) MLFeatureValue

MLFeatureValueFromID constructs a MLFeatureValue from an objc.ID.

A generic wrapper around an underlying value and the value’s type.

func NewFeatureValueUndefinedFeatureValueWithType

func NewFeatureValueUndefinedFeatureValueWithType(type_ MLFeatureType) MLFeatureValue

Creates a feature value with a type that represents an undefined or missing value.

type: The type of the undefined or missing value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(undefined:)

func NewFeatureValueWithCGImageConstraintOptionsError

func NewFeatureValueWithCGImageConstraintOptionsError(cgImage coregraphics.CGImageRef, constraint IMLImageConstraint, options foundation.INSDictionary) (MLFeatureValue, error)

Creates a feature value that contains an image defined by a core graphics image and a constraint.

cgImage: A [CGImage] instance. // [CGImage]: https://developer.apple.com/documentation/CoreGraphics/CGImage

constraint: An MLImageConstraint instance.

options: A dictionary of [VNImageCropAndScaleOption] values, each keyed by MLFeatureValueImageOption. // [VNImageCropAndScaleOption]: https://developer.apple.com/documentation/Vision/VNImageCropAndScaleOption

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(CGImage:constraint:options:)

func NewFeatureValueWithCGImageOrientationConstraintOptionsError

func NewFeatureValueWithCGImageOrientationConstraintOptionsError(cgImage coregraphics.CGImageRef, orientation objectivec.IObject, constraint IMLImageConstraint, options foundation.INSDictionary) (MLFeatureValue, error)

Creates a feature value that contains an image defined by a core graphics image, an orientation, and a constraint.

cgImage: A [CGImage] instance. // [CGImage]: https://developer.apple.com/documentation/CoreGraphics/CGImage

orientation: A [CGImagePropertyOrientation] instance. // [CGImagePropertyOrientation]: https://developer.apple.com/documentation/ImageIO/CGImagePropertyOrientation

constraint: An MLImageConstraint instance.

options: A dictionary of [VNImageCropAndScaleOption] values, each keyed by MLFeatureValueImageOption. // [VNImageCropAndScaleOption]: https://developer.apple.com/documentation/Vision/VNImageCropAndScaleOption

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(CGImage:orientation:constraint:options:) orientation is a [imageio.CGImagePropertyOrientation].

func NewFeatureValueWithCGImageOrientationPixelsWidePixelsHighPixelFormatTypeOptionsError

func NewFeatureValueWithCGImageOrientationPixelsWidePixelsHighPixelFormatTypeOptionsError(cgImage coregraphics.CGImageRef, orientation objectivec.IObject, pixelsWide int, pixelsHigh int, pixelFormatType uint32, options foundation.INSDictionary) (MLFeatureValue, error)

Creates a feature value that contains an image defined by a core graphics image and its orientation, size, and pixel format.

cgImage: A [CGImage] instance. // [CGImage]: https://developer.apple.com/documentation/CoreGraphics/CGImage

orientation: A [CGImagePropertyOrientation] instance. // [CGImagePropertyOrientation]: https://developer.apple.com/documentation/ImageIO/CGImagePropertyOrientation

pixelsWide: The image’s width in pixels.

pixelsHigh: The image’s height in pixels.

pixelFormatType: The image’s pixel format (see [Pixel Format Identifiers]). // [Pixel Format Identifiers]: https://developer.apple.com/documentation/CoreVideo/pixel-format-identifiers

options: A dictionary of [VNImageCropAndScaleOption] values, each keyed by MLFeatureValueImageOption. // [VNImageCropAndScaleOption]: https://developer.apple.com/documentation/Vision/VNImageCropAndScaleOption

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(CGImage:orientation:pixelsWide:pixelsHigh:pixelFormatType:options:) orientation is a [imageio.CGImagePropertyOrientation].

func NewFeatureValueWithCGImagePixelsWidePixelsHighPixelFormatTypeOptionsError

func NewFeatureValueWithCGImagePixelsWidePixelsHighPixelFormatTypeOptionsError(cgImage coregraphics.CGImageRef, pixelsWide int, pixelsHigh int, pixelFormatType uint32, options foundation.INSDictionary) (MLFeatureValue, error)

Creates a feature value that contains an image defined by a core graphics image and its size and pixel format.

cgImage: A [CGImage] instance. // [CGImage]: https://developer.apple.com/documentation/CoreGraphics/CGImage

pixelsWide: The image’s width in pixels.

pixelsHigh: The image’s height in pixels.

pixelFormatType: The image’s pixel format (see [Pixel Format Identifiers]). // [Pixel Format Identifiers]: https://developer.apple.com/documentation/CoreVideo/pixel-format-identifiers

options: A dictionary of [VNImageCropAndScaleOption] values, each keyed by MLFeatureValueImageOption. // [VNImageCropAndScaleOption]: https://developer.apple.com/documentation/Vision/VNImageCropAndScaleOption

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(CGImage:pixelsWide:pixelsHigh:pixelFormatType:options:)

func NewFeatureValueWithDictionaryError

func NewFeatureValueWithDictionaryError(value foundation.INSDictionary) (MLFeatureValue, error)

Creates a feature value that contains a dictionary of numbers.

value: A dictionary of numbers.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(dictionary:)

func NewFeatureValueWithDouble

func NewFeatureValueWithDouble(value float64) MLFeatureValue

Creates a feature value that contains a double.

value: A double precision floating point value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(double:)

func NewFeatureValueWithImageAtURLConstraintOptionsError

func NewFeatureValueWithImageAtURLConstraintOptionsError(url foundation.INSURL, constraint IMLImageConstraint, options foundation.INSDictionary) (MLFeatureValue, error)

Creates a feature value that contains an image defined by an image URL and a constraint.

url: A [URL] (Swift) or [NSURL] (Objective-C) to an image. // [NSURL]: https://developer.apple.com/documentation/Foundation/NSURL [URL]: https://developer.apple.com/documentation/Foundation/URL

constraint: An MLImageConstraint instance.

options: A dictionary of [VNImageCropAndScaleOption] values, each keyed by MLFeatureValueImageOption. // [VNImageCropAndScaleOption]: https://developer.apple.com/documentation/Vision/VNImageCropAndScaleOption

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(imageAtURL:constraint:options:)

func NewFeatureValueWithImageAtURLOrientationConstraintOptionsError

func NewFeatureValueWithImageAtURLOrientationConstraintOptionsError(url foundation.INSURL, orientation objectivec.IObject, constraint IMLImageConstraint, options foundation.INSDictionary) (MLFeatureValue, error)

Creates a feature value that contains an image defined by an image URL, an orientation, and a constraint.

url: A [URL] (Swift) or [NSURL] (Objective-C) to an image. // [NSURL]: https://developer.apple.com/documentation/Foundation/NSURL [URL]: https://developer.apple.com/documentation/Foundation/URL

orientation: A [CGImagePropertyOrientation] instance. // [CGImagePropertyOrientation]: https://developer.apple.com/documentation/ImageIO/CGImagePropertyOrientation

constraint: An MLImageConstraint instance.

options: A dictionary of [VNImageCropAndScaleOption] values, each keyed by MLFeatureValueImageOption. // [VNImageCropAndScaleOption]: https://developer.apple.com/documentation/Vision/VNImageCropAndScaleOption

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(imageAtURL:orientation:constraint:options:) orientation is a [imageio.CGImagePropertyOrientation].

func NewFeatureValueWithImageAtURLOrientationPixelsWidePixelsHighPixelFormatTypeOptionsError

func NewFeatureValueWithImageAtURLOrientationPixelsWidePixelsHighPixelFormatTypeOptionsError(url foundation.INSURL, orientation objectivec.IObject, pixelsWide int, pixelsHigh int, pixelFormatType uint32, options foundation.INSDictionary) (MLFeatureValue, error)

Creates a feature value that contains an image defined by an image URL and the image’s orientation, size, and pixel format.

url: A [URL] (Swift) or [NSURL] (Objective-C) to an image. // [NSURL]: https://developer.apple.com/documentation/Foundation/NSURL [URL]: https://developer.apple.com/documentation/Foundation/URL

orientation: A [CGImagePropertyOrientation] instance. // [CGImagePropertyOrientation]: https://developer.apple.com/documentation/ImageIO/CGImagePropertyOrientation

pixelsWide: The image’s width in pixels.

pixelsHigh: The image’s height in pixels.

pixelFormatType: The image’s pixel format (see [Pixel Format Identifiers]). // [Pixel Format Identifiers]: https://developer.apple.com/documentation/CoreVideo/pixel-format-identifiers

options: A dictionary of [VNImageCropAndScaleOption] values, each keyed by MLFeatureValueImageOption. // [VNImageCropAndScaleOption]: https://developer.apple.com/documentation/Vision/VNImageCropAndScaleOption

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(imageAtURL:orientation:pixelsWide:pixelsHigh:pixelFormatType:options:) orientation is a [imageio.CGImagePropertyOrientation].

func NewFeatureValueWithImageAtURLPixelsWidePixelsHighPixelFormatTypeOptionsError

func NewFeatureValueWithImageAtURLPixelsWidePixelsHighPixelFormatTypeOptionsError(url foundation.INSURL, pixelsWide int, pixelsHigh int, pixelFormatType uint32, options foundation.INSDictionary) (MLFeatureValue, error)

Creates a feature value that contains an image defined by an image URL and the image’s size and pixel format.

url: A [URL] (Swift) or [NSURL] (Objective-C) to an image. // [NSURL]: https://developer.apple.com/documentation/Foundation/NSURL [URL]: https://developer.apple.com/documentation/Foundation/URL

pixelsWide: The image’s width in pixels.

pixelsHigh: The image’s height in pixels.

pixelFormatType: The image’s pixel format (see [Pixel Format Identifiers]). // [Pixel Format Identifiers]: https://developer.apple.com/documentation/CoreVideo/pixel-format-identifiers

options: A dictionary of [VNImageCropAndScaleOption] values, each keyed by MLFeatureValueImageOption. // [VNImageCropAndScaleOption]: https://developer.apple.com/documentation/Vision/VNImageCropAndScaleOption

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(imageAtURL:pixelsWide:pixelsHigh:pixelFormatType:options:)

func NewFeatureValueWithInt64

func NewFeatureValueWithInt64(value int64) MLFeatureValue

Creates a feature value that contains an integer.

value: A 64-bit integer value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(int64:)

func NewFeatureValueWithMultiArray

func NewFeatureValueWithMultiArray(value IMLMultiArray) MLFeatureValue

Creates a feature value that contains a multidimensional array.

value: An MLMultiArray instance.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(multiArray:)

func NewFeatureValueWithPixelBuffer

func NewFeatureValueWithPixelBuffer(value corevideo.CVImageBufferRef) MLFeatureValue

Creates a feature value that contains an image from a pixel buffer.

value: A [CVPixelBuffer] (Swift) or [CVPixelBuffer] (Objective-C) instance. // [CVPixelBuffer]: https://developer.apple.com/documentation/CoreVideo/CVPixelBuffer

Discussion

Core ML supports different pixel format types depending on the model’s feature description. For information about [ImageFeatureType], see Core ML Format Reference. When the image feature’s color space is [GRAYSCALE], use kCVPixelFormatType_OneComponent8; and when it’s `GRAYSCALE_FLOAT16`, use kCVPixelFormatType_OneComponent16Half; otherwise, use kCVPixelFormatType_32BGRA when it’s set to [RGB] or [BGR].

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(pixelBuffer:)

func NewFeatureValueWithSequence

func NewFeatureValueWithSequence(sequence IMLSequence) MLFeatureValue

Creates a feature value that contains a sequence.

sequence: An MLSequence instance.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(sequence:)

func NewFeatureValueWithString

func NewFeatureValueWithString(value string) MLFeatureValue

Creates a feature value that contains a string.

value: A string.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/init(string:)

func NewMLFeatureValue

func NewMLFeatureValue() MLFeatureValue

NewMLFeatureValue creates a new MLFeatureValue instance.

func (MLFeatureValue) Autorelease

func (f MLFeatureValue) Autorelease() MLFeatureValue

Autorelease adds the receiver to the current autorelease pool.

func (MLFeatureValue) DictionaryValue

func (f MLFeatureValue) DictionaryValue() foundation.INSDictionary

The underlying dictionary of the feature value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/dictionaryValue

func (MLFeatureValue) DoubleValue

func (f MLFeatureValue) DoubleValue() float64

The underlying double of the feature value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/doubleValue

func (MLFeatureValue) EncodeWithCoder

func (f MLFeatureValue) EncodeWithCoder(coder foundation.INSCoder)

func (MLFeatureValue) ImageBufferValue

func (f MLFeatureValue) ImageBufferValue() corevideo.CVImageBufferRef

The underlying image of the feature value as a pixel buffer.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/imageBufferValue

func (MLFeatureValue) Init

func (f MLFeatureValue) Init() MLFeatureValue

Init initializes the instance.

func (MLFeatureValue) Int64Value

func (f MLFeatureValue) Int64Value() int64

The underlying integer of the feature value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/int64Value

func (MLFeatureValue) IsEqualToFeatureValue

func (f MLFeatureValue) IsEqualToFeatureValue(value IMLFeatureValue) bool

Returns a Boolean value that indicates whether a feature value is equal to another.

value: Another feature value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/isEqual(to:)

func (MLFeatureValue) MultiArrayValue

func (f MLFeatureValue) MultiArrayValue() IMLMultiArray

The underlying multiarray of the feature value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/multiArrayValue

func (MLFeatureValue) SequenceValue

func (f MLFeatureValue) SequenceValue() IMLSequence

The underlying sequence of the feature value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/sequenceValue

func (MLFeatureValue) StringValue

func (f MLFeatureValue) StringValue() string

The underlying string of the feature value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/stringValue

func (MLFeatureValue) Type

func (f MLFeatureValue) Type() MLFeatureType

The type of the feature value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/type

func (MLFeatureValue) Undefined

func (f MLFeatureValue) Undefined() bool

A Boolean value that indicates whether the feature value is undefined or missing.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/isUndefined

type MLFeatureValueClass

type MLFeatureValueClass struct {
	// contains filtered or unexported fields
}

func GetMLFeatureValueClass

func GetMLFeatureValueClass() MLFeatureValueClass

GetMLFeatureValueClass returns the class object for MLFeatureValue.

func (MLFeatureValueClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLFeatureValueImageOption

type MLFeatureValueImageOption = string

MLFeatureValueImageOption is the initializer options you use to crop and scale an image when creating an image feature value.

See: https://developer.apple.com/documentation/CoreML/MLFeatureValue/ImageOption

type MLGPUComputeDevice

type MLGPUComputeDevice struct {
	objectivec.Object
}

An object that represents a GPU compute device.

Getting the metal device

See: https://developer.apple.com/documentation/CoreML/MLGPUComputeDevice

func MLGPUComputeDeviceFromID

func MLGPUComputeDeviceFromID(id objc.ID) MLGPUComputeDevice

MLGPUComputeDeviceFromID constructs a MLGPUComputeDevice from an objc.ID.

An object that represents a GPU compute device.

func NewMLGPUComputeDevice

func NewMLGPUComputeDevice() MLGPUComputeDevice

NewMLGPUComputeDevice creates a new MLGPUComputeDevice instance.

func (MLGPUComputeDevice) Autorelease

func (g MLGPUComputeDevice) Autorelease() MLGPUComputeDevice

Autorelease adds the receiver to the current autorelease pool.

func (MLGPUComputeDevice) Init

Init initializes the instance.

func (MLGPUComputeDevice) MetalDevice

func (g MLGPUComputeDevice) MetalDevice() objectivec.IObject

The device that represents the underlying metal device.

See: https://developer.apple.com/documentation/CoreML/MLGPUComputeDevice/metalDevice

type MLGPUComputeDeviceClass

type MLGPUComputeDeviceClass struct {
	// contains filtered or unexported fields
}

func GetMLGPUComputeDeviceClass

func GetMLGPUComputeDeviceClass() MLGPUComputeDeviceClass

GetMLGPUComputeDeviceClass returns the class object for MLGPUComputeDevice.

func (MLGPUComputeDeviceClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLImageConstraint

type MLImageConstraint struct {
	objectivec.Object
}

The width, height, and pixel format constraints of an image feature.

Overview

In CoreML, an is a collection of pixels represented by CVPixelBuffer (Swift) or CVPixelBuffer (Objective-C). An is a model input or output that accepts or produces, respectively, an image bundled in an MLFeatureValue. MLImageConstraint defines the image feature’s limitations for the images within an MLFeatureValue.

If a model has an image feature for an input or output, the model author uses an by creating an MLFeatureDescription. The feature description for an image input or output has:

- Its MLImageConstraint.Type property set to MLFeatureType.image - Its [ImageConstraint] property set to an MLImageConstraint instance configured to the image feature’s size and format

Image features that support additional image sizes provide a range of sizes, or a list of discrete sizes, in their image constraint’s MLImageConstraint.SizeConstraint property.

Accessing the constraints

Inspecting acceptable sizes

See: https://developer.apple.com/documentation/CoreML/MLImageConstraint

func MLImageConstraintFromID

func MLImageConstraintFromID(id objc.ID) MLImageConstraint

MLImageConstraintFromID constructs a MLImageConstraint from an objc.ID.

The width, height, and pixel format constraints of an image feature.

func NewMLImageConstraint

func NewMLImageConstraint() MLImageConstraint

NewMLImageConstraint creates a new MLImageConstraint instance.

func (MLImageConstraint) Autorelease

func (i MLImageConstraint) Autorelease() MLImageConstraint

Autorelease adds the receiver to the current autorelease pool.

func (MLImageConstraint) EncodeWithCoder

func (i MLImageConstraint) EncodeWithCoder(coder foundation.INSCoder)

func (MLImageConstraint) ImageConstraint

func (i MLImageConstraint) ImageConstraint() IMLImageConstraint

The size and format constraints for an image feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/imageconstraint

func (MLImageConstraint) Init

Init initializes the instance.

func (MLImageConstraint) PixelFormatType

func (i MLImageConstraint) PixelFormatType() uint32

The model’s pixel format for an image feature.

See: https://developer.apple.com/documentation/CoreML/MLImageConstraint/pixelFormatType

func (MLImageConstraint) PixelsHigh

func (i MLImageConstraint) PixelsHigh() int

The model’s default height for an image feature.

See: https://developer.apple.com/documentation/CoreML/MLImageConstraint/pixelsHigh

func (MLImageConstraint) PixelsWide

func (i MLImageConstraint) PixelsWide() int

The model’s default width for an image feature.

See: https://developer.apple.com/documentation/CoreML/MLImageConstraint/pixelsWide

func (MLImageConstraint) SetImageConstraint

func (i MLImageConstraint) SetImageConstraint(value IMLImageConstraint)

func (MLImageConstraint) SetType

func (i MLImageConstraint) SetType(value MLFeatureType)

func (MLImageConstraint) SizeConstraint

func (i MLImageConstraint) SizeConstraint() IMLImageSizeConstraint

Additional sizes this image feature supports.

See: https://developer.apple.com/documentation/CoreML/MLImageConstraint/sizeConstraint

func (MLImageConstraint) Type

The type of this feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/type

type MLImageConstraintClass

type MLImageConstraintClass struct {
	// contains filtered or unexported fields
}

func GetMLImageConstraintClass

func GetMLImageConstraintClass() MLImageConstraintClass

GetMLImageConstraintClass returns the class object for MLImageConstraint.

func (MLImageConstraintClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLImageSize

type MLImageSize struct {
	objectivec.Object
}

The width and height of an image feature size.

Accessing an image size

See: https://developer.apple.com/documentation/CoreML/MLImageSize

func MLImageSizeFromID

func MLImageSizeFromID(id objc.ID) MLImageSize

MLImageSizeFromID constructs a MLImageSize from an objc.ID.

The width and height of an image feature size.

func NewMLImageSize

func NewMLImageSize() MLImageSize

NewMLImageSize creates a new MLImageSize instance.

func (MLImageSize) Autorelease

func (i MLImageSize) Autorelease() MLImageSize

Autorelease adds the receiver to the current autorelease pool.

func (MLImageSize) EncodeWithCoder

func (i MLImageSize) EncodeWithCoder(coder foundation.INSCoder)

func (MLImageSize) EnumeratedImageSizes

func (i MLImageSize) EnumeratedImageSizes() IMLImageSize

An array of image sizes a model’s image feature accepts as input or produces as output.

See: https://developer.apple.com/documentation/coreml/mlimagesizeconstraint/enumeratedimagesizes

func (MLImageSize) Init

func (i MLImageSize) Init() MLImageSize

Init initializes the instance.

func (MLImageSize) PixelsHigh

func (i MLImageSize) PixelsHigh() int

The height of an image feature in pixels.

See: https://developer.apple.com/documentation/CoreML/MLImageSize/pixelsHigh

func (MLImageSize) PixelsWide

func (i MLImageSize) PixelsWide() int

The width of an image feature in pixels.

See: https://developer.apple.com/documentation/CoreML/MLImageSize/pixelsWide

func (MLImageSize) SetEnumeratedImageSizes

func (i MLImageSize) SetEnumeratedImageSizes(value IMLImageSize)

type MLImageSizeClass

type MLImageSizeClass struct {
	// contains filtered or unexported fields
}

func GetMLImageSizeClass

func GetMLImageSizeClass() MLImageSizeClass

GetMLImageSizeClass returns the class object for MLImageSize.

func (MLImageSizeClass) Alloc

func (mc MLImageSizeClass) Alloc() MLImageSize

Alloc allocates memory for a new instance of the class.

type MLImageSizeConstraint

type MLImageSizeConstraint struct {
	objectivec.Object
}

A list or range of sizes that augment an image constraint’s default size.

Overview

You use an MLImageSizeConstraint to express what image sizes of an image feature a model will accept as input or produce as output.

Use MLImageSizeConstraint.Type to determine which properties describe what image sizes the model’s image feature expects as input or produces as output.

If `type` is:

- MLImageSizeConstraintType.range, the image feature accepts any image that has a width in MLImageSizeConstraint.PixelsWideRange and a height in MLImageSizeConstraint.PixelsHighRange. - MLImageSizeConstraintType.enumerated, the image feature accepts any image size listed in MLImageSizeConstraint.EnumeratedImageSizes. - MLImageSizeConstraintType.unspecified, the MLImageSizeConstraint instance is not configured and should be ignored. Instead, use the image feature’s default image size constraint, defined by MLImageSizeConstraint.PixelsWide and MLImageSizeConstraint.PixelsHigh.

[media-3027121]

Determining relevant constraints

Accessing the image size ranges

Accessing the enumerated image sizes

See: https://developer.apple.com/documentation/CoreML/MLImageSizeConstraint

func MLImageSizeConstraintFromID

func MLImageSizeConstraintFromID(id objc.ID) MLImageSizeConstraint

MLImageSizeConstraintFromID constructs a MLImageSizeConstraint from an objc.ID.

A list or range of sizes that augment an image constraint’s default size.

func NewMLImageSizeConstraint

func NewMLImageSizeConstraint() MLImageSizeConstraint

NewMLImageSizeConstraint creates a new MLImageSizeConstraint instance.

func (MLImageSizeConstraint) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLImageSizeConstraint) EncodeWithCoder

func (i MLImageSizeConstraint) EncodeWithCoder(coder foundation.INSCoder)

func (MLImageSizeConstraint) EnumeratedImageSizes

func (i MLImageSizeConstraint) EnumeratedImageSizes() []MLImageSize

An array of image sizes a model’s image feature accepts as input or produces as output.

See: https://developer.apple.com/documentation/CoreML/MLImageSizeConstraint/enumeratedImageSizes

func (MLImageSizeConstraint) Init

Init initializes the instance.

func (MLImageSizeConstraint) PixelsHigh

func (i MLImageSizeConstraint) PixelsHigh() int

The model’s default height for an image feature.

See: https://developer.apple.com/documentation/coreml/mlimageconstraint/pixelshigh

func (MLImageSizeConstraint) PixelsHighRange

func (i MLImageSizeConstraint) PixelsHighRange() foundation.NSRange

The range of heights a model’s image feature accepts as input or produces as output.

See: https://developer.apple.com/documentation/CoreML/MLImageSizeConstraint/pixelsHighRange

func (MLImageSizeConstraint) PixelsWide

func (i MLImageSizeConstraint) PixelsWide() int

The model’s default width for an image feature.

See: https://developer.apple.com/documentation/coreml/mlimageconstraint/pixelswide

func (MLImageSizeConstraint) PixelsWideRange

func (i MLImageSizeConstraint) PixelsWideRange() foundation.NSRange

The range of widths a model’s image feature accepts as input or produces as output.

See: https://developer.apple.com/documentation/CoreML/MLImageSizeConstraint/pixelsWideRange

func (MLImageSizeConstraint) SetPixelsHigh

func (i MLImageSizeConstraint) SetPixelsHigh(value int)

func (MLImageSizeConstraint) SetPixelsWide

func (i MLImageSizeConstraint) SetPixelsWide(value int)

func (MLImageSizeConstraint) SetSizeConstraint

func (i MLImageSizeConstraint) SetSizeConstraint(value IMLImageSizeConstraint)

func (MLImageSizeConstraint) SizeConstraint

func (i MLImageSizeConstraint) SizeConstraint() IMLImageSizeConstraint

Additional sizes this image feature supports.

See: https://developer.apple.com/documentation/coreml/mlimageconstraint/sizeconstraint

func (MLImageSizeConstraint) Type

Indicator of which properties to inspect for this image size constraint.

See: https://developer.apple.com/documentation/CoreML/MLImageSizeConstraint/type

type MLImageSizeConstraintClass

type MLImageSizeConstraintClass struct {
	// contains filtered or unexported fields
}

func GetMLImageSizeConstraintClass

func GetMLImageSizeConstraintClass() MLImageSizeConstraintClass

GetMLImageSizeConstraintClass returns the class object for MLImageSizeConstraint.

func (MLImageSizeConstraintClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLImageSizeConstraintType

type MLImageSizeConstraintType int

See: https://developer.apple.com/documentation/CoreML/MLImageSizeConstraintType

const (
	// MLImageSizeConstraintTypeEnumerated: The image feature accepts image sizes listed in an array.
	MLImageSizeConstraintTypeEnumerated MLImageSizeConstraintType = 2
	// MLImageSizeConstraintTypeRange: The image feature accepts image sizes defined by a range of widths and a range of heights.
	MLImageSizeConstraintTypeRange MLImageSizeConstraintType = 3
	// MLImageSizeConstraintTypeUnspecified: The image size constraint is not configured and should be ignored.
	MLImageSizeConstraintTypeUnspecified MLImageSizeConstraintType = 0
)

func (MLImageSizeConstraintType) String

func (e MLImageSizeConstraintType) String() string

type MLKey

type MLKey struct {
	objectivec.Object
}

An abstract base class for machine learning key types.

Overview

You don’t create use this class directly. Instead, use a class that inherits from this one, such as MLParameterKey or MLMetricKey.

Retrieving a key’s information

  • MLKey.Name: The name of the machine learning key.
  • MLKey.Scope: The applicable scope of the machine learning key.

See: https://developer.apple.com/documentation/CoreML/MLKey

func MLKeyFromID

func MLKeyFromID(id objc.ID) MLKey

MLKeyFromID constructs a MLKey from an objc.ID.

An abstract base class for machine learning key types.

func NewMLKey

func NewMLKey() MLKey

NewMLKey creates a new MLKey instance.

func (MLKey) Autorelease

func (k MLKey) Autorelease() MLKey

Autorelease adds the receiver to the current autorelease pool.

func (MLKey) EncodeWithCoder

func (k MLKey) EncodeWithCoder(coder foundation.INSCoder)

func (MLKey) Init

func (k MLKey) Init() MLKey

Init initializes the instance.

func (MLKey) Name

func (k MLKey) Name() string

The name of the machine learning key.

See: https://developer.apple.com/documentation/CoreML/MLKey/name

func (MLKey) Scope

func (k MLKey) Scope() string

The applicable scope of the machine learning key.

See: https://developer.apple.com/documentation/CoreML/MLKey/scope

type MLKeyClass

type MLKeyClass struct {
	// contains filtered or unexported fields
}

func GetMLKeyClass

func GetMLKeyClass() MLKeyClass

GetMLKeyClass returns the class object for MLKey.

func (MLKeyClass) Alloc

func (mc MLKeyClass) Alloc() MLKey

Alloc allocates memory for a new instance of the class.

type MLMetricKey

type MLMetricKey struct {
	MLKey
}

A key for the metrics dictionary in an update context.

See: https://developer.apple.com/documentation/CoreML/MLMetricKey

func MLMetricKeyFromID

func MLMetricKeyFromID(id objc.ID) MLMetricKey

MLMetricKeyFromID constructs a MLMetricKey from an objc.ID.

A key for the metrics dictionary in an update context.

func NewMLMetricKey

func NewMLMetricKey() MLMetricKey

NewMLMetricKey creates a new MLMetricKey instance.

func (MLMetricKey) Autorelease

func (m MLMetricKey) Autorelease() MLMetricKey

Autorelease adds the receiver to the current autorelease pool.

func (MLMetricKey) Init

func (m MLMetricKey) Init() MLMetricKey

Init initializes the instance.

func (MLMetricKey) Metrics

func (m MLMetricKey) Metrics() IMLMetricKey

The training metrics of the model for the update task, contained in a dictionary.

See: https://developer.apple.com/documentation/coreml/mlupdatecontext/metrics

func (MLMetricKey) SetMetrics

func (m MLMetricKey) SetMetrics(value IMLMetricKey)

type MLMetricKeyClass

type MLMetricKeyClass struct {
	// contains filtered or unexported fields
}

func GetMLMetricKeyClass

func GetMLMetricKeyClass() MLMetricKeyClass

GetMLMetricKeyClass returns the class object for MLMetricKey.

func (MLMetricKeyClass) Alloc

func (mc MLMetricKeyClass) Alloc() MLMetricKey

Alloc allocates memory for a new instance of the class.

func (MLMetricKeyClass) EpochIndex

func (_MLMetricKeyClass MLMetricKeyClass) EpochIndex() MLMetricKey

The key you use to access the epoch index (an [Int64] value).

Discussion

Use this key to fetch the epoch index value in the [Metrics] dictionary.

See: https://developer.apple.com/documentation/CoreML/MLMetricKey/epochIndex

func (MLMetricKeyClass) LossValue

func (_MLMetricKeyClass MLMetricKeyClass) LossValue() MLMetricKey

The key you use to access the current loss (a `float` value).

Discussion

Use this key to fetch the loss value in the [Metrics] dictionary.

See: https://developer.apple.com/documentation/CoreML/MLMetricKey/lossValue

func (MLMetricKeyClass) MiniBatchIndex

func (_MLMetricKeyClass MLMetricKeyClass) MiniBatchIndex() MLMetricKey

The key you use to access the mini-batch index (an [Int64] value) within an epoch.

Discussion

Use this key to fetch the mini-batch index value in the [Metrics] dictionary.

See: https://developer.apple.com/documentation/CoreML/MLMetricKey/miniBatchIndex

type MLModel

type MLModel struct {
	objectivec.Object
}

An encapsulation of all the details of your machine learning model.

Overview

MLModel encapsulates a model’s prediction methods, configuration, and model description.

In most cases, you can use Core ML without accessing the MLModel class directly. Instead, use the programmer-friendly wrapper class that Xcode automatically generates when you add a model (see Integrating a Core ML Model into Your App). If your app needs the MLModel interface, use the wrapper class’s `model` property.

With the MLModel interface, you can:

- Make a prediction with your app’s custom MLFeatureProvider by calling prediction(from:) or prediction(from:options:). - Make multiple predictions with your app’s custom MLBatchProvider by calling MLModel.PredictionsFromBatchError or MLModel.PredictionsFromBatchOptionsError. - Inspect your model’s MLModel.Metadata and MLFeatureDescription instances through [ModelDescription].

If your app downloads and compiles a model on the user’s device, you must use the MLModel class directly to make predictions. See Downloading and Compiling a Model on the User’s Device.

Making predictions

Inspecting a model

See: https://developer.apple.com/documentation/CoreML/MLModel

func MLModelFromID

func MLModelFromID(id objc.ID) MLModel

MLModelFromID constructs a MLModel from an objc.ID.

An encapsulation of all the details of your machine learning model.

func NewMLModel

func NewMLModel() MLModel

NewMLModel creates a new MLModel instance.

func NewModelWithContentsOfURLConfigurationError

func NewModelWithContentsOfURLConfigurationError(url foundation.INSURL, configuration IMLModelConfiguration) (MLModel, error)

Creates a Core ML model instance from a compiled model file and a custom configuration.

url: The path to a compiled model file (`XCUIElementTypeMlmodelc`), typically with the [URL] that [compileModel(at:)] returns. // [compileModel(at:)]: https://developer.apple.com/documentation/CoreML/MLModel/compileModel(at:)-6442s

configuration: The runtime settings for the new model instance.

Discussion

In most cases, your app won’t need to create a model object directly. Consider the programmer-friendly wrapper class that Xcode automatically generates when you add a model to your project (see Integrating a Core ML Model into Your App).

If the wrapper class doesn’t meet your app’s needs or you need to customize the model’s configuration, use this initializer to create a model object from any compiled model file you can access. Typically, you use this initializer after your app has downloaded and compiled a model, which is one technique for saving space in your app (see Downloading and Compiling a Model on the User’s Device).

See: https://developer.apple.com/documentation/CoreML/MLModel/init(contentsOf:configuration:)

func NewModelWithContentsOfURLError

func NewModelWithContentsOfURLError(url foundation.INSURL) (MLModel, error)

Creates a Core ML model instance from a compiled model file.

url: The path to a compiled model file (`XCUIElementTypeMlmodelc`), typically with the [URL] that [compileModel(at:)] returns. // [compileModel(at:)]: https://developer.apple.com/documentation/CoreML/MLModel/compileModel(at:)-6442s

Discussion

In most cases, your app won’t need to create a model object directly. Consider the programmer-friendly wrapper class that Xcode automatically generates when you add a model to your project (see Integrating a Core ML Model into Your App).

If the wrapper class doesn’t meet your app’s needs or you need to customize the model’s configuration, use this initializer to create a model object from any compiled model file you can access. Typically, you use this initializer after your app has downloaded and compiled a model, which is one technique for saving space in your app (see Downloading and Compiling a Model on the User’s Device).

See: https://developer.apple.com/documentation/CoreML/MLModel/init(contentsOf:)

func (MLModel) Autorelease

func (m MLModel) Autorelease() MLModel

Autorelease adds the receiver to the current autorelease pool.

func (MLModel) AvailableComputeDevices

func (m MLModel) AvailableComputeDevices() objectivec.IObject

The list of available compute devices that the model’s prediction methods use.

See: https://developer.apple.com/documentation/coreml/mlmodel/availablecomputedevices-6klyt

func (MLModel) Configuration

func (m MLModel) Configuration() IMLModelConfiguration

The configuration of the model set during initialization.

See: https://developer.apple.com/documentation/CoreML/MLModel/configuration

func (MLModel) Init

func (m MLModel) Init() MLModel

Init initializes the instance.

func (MLModel) Metadata

func (m MLModel) Metadata() MLModelMetadataKey

A dictionary of the model’s creation information, such as its description, author, version, and license.

See: https://developer.apple.com/documentation/coreml/mlmodeldescription/metadata

func (MLModel) ModelDescription

func (m MLModel) ModelDescription() IMLModelDescription

Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.

See: https://developer.apple.com/documentation/CoreML/MLModel/modelDescription

func (MLModel) ParameterValueForKeyError

func (m MLModel) ParameterValueForKeyError(key IMLParameterKey) (objectivec.IObject, error)

Returns a model parameter value for a key.

key: The key to a model parameter value.

See: https://developer.apple.com/documentation/CoreML/MLModel/parameterValue(for:)

func (MLModel) PredictionsFromBatchError

func (m MLModel) PredictionsFromBatchError(inputBatch MLBatchProvider) (MLBatchProvider, error)

Generates predictions for each input feature provider within the batch provider.

inputBatch: A batch provider that contains multiple input feature providers. The model makes a prediction for each feature provider.

Return Value

A batch provider that contains an output feature provider for each prediction.

Discussion

Use this method to make more than one prediction at one time.

See: https://developer.apple.com/documentation/CoreML/MLModel/predictions(fromBatch:)

func (MLModel) PredictionsFromBatchOptionsError

func (m MLModel) PredictionsFromBatchOptionsError(inputBatch MLBatchProvider, options IMLPredictionOptions) (MLBatchProvider, error)

Generates a prediction for each input feature provider within the batch provider using the prediction options.

inputBatch: A batch provider that contains multiple input feature providers. The model makes a prediction for each feature provider.

options: The runtime settings the model uses as it makes a prediction.

Return Value

A batch provider that contains an output feature provider for each prediction.

Discussion

Use this method to make more than one prediction at one time.

See: https://developer.apple.com/documentation/CoreML/MLModel/predictions(from:options:)

func (MLModel) SetAvailableComputeDevices

func (m MLModel) SetAvailableComputeDevices(value objectivec.IObject)

func (MLModel) SetMetadata

func (m MLModel) SetMetadata(value MLModelMetadataKey)

type MLModelAsset

type MLModelAsset struct {
	objectivec.Object
}

An abstraction of a compiled Core ML model asset.

Overview

MLModelAsset provides a unified interface by abstracting the compiled model representations for `XCUIElementTypeMlmodelc` files and in-memory representations.

To use an in-memory model, create an MLModelAsset with an in-memory model specification, then call [LoadModelAssetConfigurationCompletionHandler].

Getting function names

Getting the model description

See: https://developer.apple.com/documentation/CoreML/MLModelAsset

func MLModelAssetFromID

func MLModelAssetFromID(id objc.ID) MLModelAsset

MLModelAssetFromID constructs a MLModelAsset from an objc.ID.

An abstraction of a compiled Core ML model asset.

func NewMLModelAsset

func NewMLModelAsset() MLModelAsset

NewMLModelAsset creates a new MLModelAsset instance.

func NewModelAssetWithSpecificationDataBlobMappingError

func NewModelAssetWithSpecificationDataBlobMappingError(specificationData foundation.INSData, blobMapping foundation.INSDictionary) (MLModelAsset, error)

Construct a model asset from an ML Program specification by replacing blob file references with corresponding in-memory blobs.

blobMapping: A dictionary with blob URL as the key and blob data as the value.

Discussion

An ML Program may use [BlobFileValue] syntax, which stores the blob data in external files and refers them by URL. This factory method enables in-memory workflow for such models by using the specified in-memory blob data in place of the external files.

The format of in-memory blobs must be the same as the external files. The dictionary must contain all the reference URLs used in the specification.

See: https://developer.apple.com/documentation/CoreML/MLModelAsset/init(specification:blobMapping:)

func NewModelAssetWithSpecificationDataError

func NewModelAssetWithSpecificationDataError(specificationData foundation.INSData) (MLModelAsset, error)

Creates a model asset from an in-memory model specification.

specificationData: The contents of a `XCUIElementTypeMlmodel` as a data blob.

See: https://developer.apple.com/documentation/CoreML/MLModelAsset/init(specification:)

func NewModelAssetWithURLError

func NewModelAssetWithURLError(compiledModelURL foundation.INSURL) (MLModelAsset, error)

Constructs a ModelAsset from a compiled model URL.

compiledModelURL: Location on the disk where the model asset is present.

Return Value

A model asset or nil if there is an error.

See: https://developer.apple.com/documentation/CoreML/MLModelAsset/init(url:)

func (MLModelAsset) Autorelease

func (m MLModelAsset) Autorelease() MLModelAsset

Autorelease adds the receiver to the current autorelease pool.

func (MLModelAsset) FunctionNames

func (m MLModelAsset) FunctionNames(ctx context.Context) error

FunctionNames is a synchronous wrapper around MLModelAsset.FunctionNamesWithCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (MLModelAsset) FunctionNamesWithCompletionHandler

func (m MLModelAsset) FunctionNamesWithCompletionHandler(handler ErrorHandler)

The list of function names in the model asset.

Discussion

Some model types (e.g. ML Program) supports multiple functions. Use this method to query the function names.

The method vends the empty array when the model doesn’t use the multi-function configuration.

See: https://developer.apple.com/documentation/CoreML/MLModelAsset/functionNames(completionHandler:)

func (MLModelAsset) Init

func (m MLModelAsset) Init() MLModelAsset

Init initializes the instance.

func (MLModelAsset) ModelDescription

func (m MLModelAsset) ModelDescription(ctx context.Context) (*MLModelDescription, error)

ModelDescription is a synchronous wrapper around MLModelAsset.ModelDescriptionWithCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (MLModelAsset) ModelDescriptionOfFunctionNamed

func (m MLModelAsset) ModelDescriptionOfFunctionNamed(ctx context.Context, functionName string) (*MLModelDescription, error)

ModelDescriptionOfFunctionNamed is a synchronous wrapper around MLModelAsset.ModelDescriptionOfFunctionNamedCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (MLModelAsset) ModelDescriptionOfFunctionNamedCompletionHandler

func (m MLModelAsset) ModelDescriptionOfFunctionNamedCompletionHandler(functionName string, handler MLModelDescriptionErrorHandler)

The model descripton for a specified function.

Discussion

Use this method to get the description of the model such as the feature descriptions, the model author, and other metadata.

See: https://developer.apple.com/documentation/CoreML/MLModelAsset/modelDescription(ofFunctionNamed:completionHandler:)

func (MLModelAsset) ModelDescriptionWithCompletionHandler

func (m MLModelAsset) ModelDescriptionWithCompletionHandler(handler MLModelDescriptionErrorHandler)

The default model descripton.

Discussion

Use this method to get the description of the model such as the feature descriptions, the model author, and other metadata.

For the multi-function model asset, this method vends the description for the default function. Use `modelDescription()` to get the model description of other functions.

See: https://developer.apple.com/documentation/CoreML/MLModelAsset/modelDescription(completionHandler:)

type MLModelAssetClass

type MLModelAssetClass struct {
	// contains filtered or unexported fields
}

func GetMLModelAssetClass

func GetMLModelAssetClass() MLModelAssetClass

GetMLModelAssetClass returns the class object for MLModelAsset.

func (MLModelAssetClass) Alloc

func (mc MLModelAssetClass) Alloc() MLModelAsset

Alloc allocates memory for a new instance of the class.

type MLModelClass

type MLModelClass struct {
	// contains filtered or unexported fields
}

func GetMLModelClass

func GetMLModelClass() MLModelClass

GetMLModelClass returns the class object for MLModel.

func (MLModelClass) Alloc

func (mc MLModelClass) Alloc() MLModel

Alloc allocates memory for a new instance of the class.

func (MLModelClass) LoadModelAssetConfiguration

func (mc MLModelClass) LoadModelAssetConfiguration(ctx context.Context, asset IMLModelAsset, configuration IMLModelConfiguration) (*MLModel, error)

LoadModelAssetConfiguration is a synchronous wrapper around [MLModel.LoadModelAssetConfigurationCompletionHandler]. It blocks until the completion handler fires or the context is cancelled.

func (MLModelClass) LoadModelAssetConfigurationCompletionHandler

func (_MLModelClass MLModelClass) LoadModelAssetConfigurationCompletionHandler(asset IMLModelAsset, configuration IMLModelConfiguration, handler MLModelErrorHandler)

Construct a model asynchronously from a compiled model asset.

asset: The compiled model asset derived from in-memory or on-disk Core ML model.

configuration: The model configuration that holds options for loading the model.

handler: The completion handler invoked when the load completes. A valid MLModel returns on success, or an error if failure.

See: https://developer.apple.com/documentation/CoreML/MLModel/load(_:configuration:completionHandler:)

type MLModelConfiguration

type MLModelConfiguration struct {
	objectivec.Object
}

The settings for creating or updating a machine learning model.

Overview

Use a model configuration to:

- Set or override model parameters. - Designate which device the model uses to make predictions, such as a GPU. - Restrict the model to use a specific computational device category, such as a CPU.

You typically use a model configuration instance to configure an MLModel instance as you create it with [ModelWithContentsOfURLConfigurationError] or create an MLUpdateTask. See Personalizing a Model with On-Device Updates.

Configure your model parameters by setting values for each relevant MLParameterKey in the MLModelConfiguration.Parameters property.

Configuring model parameters

Configuring GPU usage

Allowing access to processing units

Getting optimization hints

See: https://developer.apple.com/documentation/CoreML/MLModelConfiguration

func MLModelConfigurationFromID

func MLModelConfigurationFromID(id objc.ID) MLModelConfiguration

MLModelConfigurationFromID constructs a MLModelConfiguration from an objc.ID.

The settings for creating or updating a machine learning model.

func NewMLModelConfiguration

func NewMLModelConfiguration() MLModelConfiguration

NewMLModelConfiguration creates a new MLModelConfiguration instance.

func (MLModelConfiguration) AllowLowPrecisionAccumulationOnGPU

func (m MLModelConfiguration) AllowLowPrecisionAccumulationOnGPU() bool

A Boolean value that determines whether to allow low-precision accumulation on a GPU.

See: https://developer.apple.com/documentation/CoreML/MLModelConfiguration/allowLowPrecisionAccumulationOnGPU

func (MLModelConfiguration) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelConfiguration) ComputeUnits

func (m MLModelConfiguration) ComputeUnits() MLComputeUnits

The processing unit or units the model uses to make predictions.

See: https://developer.apple.com/documentation/CoreML/MLModelConfiguration/computeUnits

func (MLModelConfiguration) EncodeWithCoder

func (m MLModelConfiguration) EncodeWithCoder(coder foundation.INSCoder)

func (MLModelConfiguration) FunctionName

func (m MLModelConfiguration) FunctionName() string

Function name that MLModel will use.

Discussion

Some model types (e.g. ML Program) supports multiple functions in a model asset, where each MLModel instance is associated with a particular function.

Use MLModelAsset to get the list of available functions. Use `nil` to use a default function.

See: https://developer.apple.com/documentation/CoreML/MLModelConfiguration/functionName

func (MLModelConfiguration) Init

Init initializes the instance.

func (MLModelConfiguration) ModelDisplayName

func (m MLModelConfiguration) ModelDisplayName() string

A human readable name of a model for display purposes.

See: https://developer.apple.com/documentation/CoreML/MLModelConfiguration/modelDisplayName

func (MLModelConfiguration) OptimizationHints

func (m MLModelConfiguration) OptimizationHints() IMLOptimizationHints

A group of hints for CoreML to optimize

See: https://developer.apple.com/documentation/coreml/mlmodelconfiguration/optimizationhints-1oq0g

func (MLModelConfiguration) Parameters

A dictionary of configuration settings your app can override when loading a model.

See: https://developer.apple.com/documentation/CoreML/MLModelConfiguration/parameters

func (MLModelConfiguration) PreferredMetalDevice

func (m MLModelConfiguration) PreferredMetalDevice() objectivec.IObject

The metal device you prefer this model use to make predictions (inference) and update the model.

Discussion

If [PreferredMetalDevice] is `nil`, the default value, Core ML chooses a metal device for you.

See: https://developer.apple.com/documentation/CoreML/MLModelConfiguration/preferredMetalDevice

func (MLModelConfiguration) SetAllowLowPrecisionAccumulationOnGPU

func (m MLModelConfiguration) SetAllowLowPrecisionAccumulationOnGPU(value bool)

func (MLModelConfiguration) SetComputeUnits

func (m MLModelConfiguration) SetComputeUnits(value MLComputeUnits)

func (MLModelConfiguration) SetFunctionName

func (m MLModelConfiguration) SetFunctionName(value string)

func (MLModelConfiguration) SetModelDisplayName

func (m MLModelConfiguration) SetModelDisplayName(value string)

func (MLModelConfiguration) SetOptimizationHints

func (m MLModelConfiguration) SetOptimizationHints(value IMLOptimizationHints)

func (MLModelConfiguration) SetParameters

func (m MLModelConfiguration) SetParameters(value foundation.INSDictionary)

func (MLModelConfiguration) SetPreferredMetalDevice

func (m MLModelConfiguration) SetPreferredMetalDevice(value objectivec.IObject)

type MLModelConfigurationClass

type MLModelConfigurationClass struct {
	// contains filtered or unexported fields
}

func GetMLModelConfigurationClass

func GetMLModelConfigurationClass() MLModelConfigurationClass

GetMLModelConfigurationClass returns the class object for MLModelConfiguration.

func (MLModelConfigurationClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelDescription

type MLModelDescription struct {
	objectivec.Object
}

Information about a model, primarily the input and output format for each feature the model expects, and optional metadata.

Accessing feature descriptions

Accessing metadata

Accessing prediction names

Accessing update descriptions

See: https://developer.apple.com/documentation/CoreML/MLModelDescription

func MLModelDescriptionFromID

func MLModelDescriptionFromID(id objc.ID) MLModelDescription

MLModelDescriptionFromID constructs a MLModelDescription from an objc.ID.

Information about a model, primarily the input and output format for each feature the model expects, and optional metadata.

func NewMLModelDescription

func NewMLModelDescription() MLModelDescription

NewMLModelDescription creates a new MLModelDescription instance.

func (MLModelDescription) Autorelease

func (m MLModelDescription) Autorelease() MLModelDescription

Autorelease adds the receiver to the current autorelease pool.

func (MLModelDescription) AvailableComputeDevices

func (m MLModelDescription) AvailableComputeDevices() objectivec.IObject

The list of available compute devices that the model’s prediction methods use.

See: https://developer.apple.com/documentation/coreml/mlmodel/availablecomputedevices-6klyt

func (MLModelDescription) ClassLabels

func (m MLModelDescription) ClassLabels() []objectivec.IObject

An array of labels, which can be either strings or a numbers, for classifier models.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/classLabels

func (MLModelDescription) Configuration

func (m MLModelDescription) Configuration() IMLModelConfiguration

The configuration of the model set during initialization.

See: https://developer.apple.com/documentation/coreml/mlmodel/configuration

func (MLModelDescription) EncodeWithCoder

func (m MLModelDescription) EncodeWithCoder(coder foundation.INSCoder)

func (MLModelDescription) Init

Init initializes the instance.

func (MLModelDescription) InputDescriptionsByName

func (m MLModelDescription) InputDescriptionsByName() foundation.INSDictionary

A dictionary of input feature descriptions, which the model keys by the input’s name.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/inputDescriptionsByName

func (MLModelDescription) IsUpdatable

func (m MLModelDescription) IsUpdatable() bool

A Boolean value that indicates whether you can update the model with additional training.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/isUpdatable

func (MLModelDescription) Metadata

A dictionary of the model’s creation information, such as its description, author, version, and license.

Discussion

Use the keys defined by MLModelMetadataKey to retrieve the dictionary’s entries.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/metadata

func (MLModelDescription) ModelDescription

func (m MLModelDescription) ModelDescription() IMLModelDescription

Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.

See: https://developer.apple.com/documentation/coreml/mlmodel/modeldescription

func (MLModelDescription) OutputDescriptionsByName

func (m MLModelDescription) OutputDescriptionsByName() foundation.INSDictionary

A dictionary of output feature descriptions, which the model keys by the output’s name.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/outputDescriptionsByName

func (MLModelDescription) ParameterDescriptionsByKey

func (m MLModelDescription) ParameterDescriptionsByKey() foundation.INSDictionary

A dictionary of the descriptions for the model’s parameters.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/parameterDescriptionsByKey

func (MLModelDescription) PredictedFeatureName

func (m MLModelDescription) PredictedFeatureName() string

The name of the primary prediction feature output description.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/predictedFeatureName

func (MLModelDescription) PredictedProbabilitiesName

func (m MLModelDescription) PredictedProbabilitiesName() string

The name of the feature output description for all probabilities of a prediction.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/predictedProbabilitiesName

func (MLModelDescription) SetAvailableComputeDevices

func (m MLModelDescription) SetAvailableComputeDevices(value objectivec.IObject)

func (MLModelDescription) SetConfiguration

func (m MLModelDescription) SetConfiguration(value IMLModelConfiguration)

func (MLModelDescription) SetModelDescription

func (m MLModelDescription) SetModelDescription(value IMLModelDescription)

func (MLModelDescription) StateDescriptionsByName

func (m MLModelDescription) StateDescriptionsByName() foundation.INSDictionary

Description of the state features.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/stateDescriptionsByName

func (MLModelDescription) TrainingInputDescriptionsByName

func (m MLModelDescription) TrainingInputDescriptionsByName() foundation.INSDictionary

A dictionary of the training input feature descriptions, which the model keys by the input’s name.

See: https://developer.apple.com/documentation/CoreML/MLModelDescription/trainingInputDescriptionsByName

type MLModelDescriptionClass

type MLModelDescriptionClass struct {
	// contains filtered or unexported fields
}

func GetMLModelDescriptionClass

func GetMLModelDescriptionClass() MLModelDescriptionClass

GetMLModelDescriptionClass returns the class object for MLModelDescription.

func (MLModelDescriptionClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelDescriptionErrorHandler

type MLModelDescriptionErrorHandler = func(*MLModelDescription, error)

MLModelDescriptionErrorHandler is the signature for a completion handler block.

Used by:

type MLModelError

type MLModelError int

See: https://developer.apple.com/documentation/CoreML/MLModelError-swift.struct/Code

const (
	// MLModelErrorCustomLayer: An error code for problems related to custom layers.
	MLModelErrorCustomLayer MLModelError = 4
	// MLModelErrorCustomModel: An error code for problems related to custom models.
	MLModelErrorCustomModel MLModelError = 5
	// MLModelErrorFeatureType: An error code for problems related to model features.
	MLModelErrorFeatureType MLModelError = 1
	// MLModelErrorGeneric: An error code for runtime issues that don’t apply to the other error codes.
	MLModelErrorGeneric MLModelError = 0
	// MLModelErrorIO: An error code for problems related to the system’s input or output.
	MLModelErrorIO MLModelError = 3
	// MLModelErrorModelCollection: An error code for problems related to retrieving a model collection from the deployment system.
	MLModelErrorModelCollection MLModelError = 10
	// MLModelErrorModelDecryption: An error code for problems related to decrypting models.
	MLModelErrorModelDecryption MLModelError = 9
	// MLModelErrorModelDecryptionKeyFetch: An error code for problems related to retrieving a model’s decryption key.
	MLModelErrorModelDecryptionKeyFetch MLModelError = 8
	// MLModelErrorParameters: An error code for problems related to model parameters.
	MLModelErrorParameters MLModelError = 7
	// MLModelErrorPredictionCancelled: An error code for problems related to canceling the prediction before it completes.
	MLModelErrorPredictionCancelled MLModelError = 11
	// MLModelErrorUpdate: An error code for problems related to on-device model updates.
	MLModelErrorUpdate MLModelError = 6
)

func (MLModelError) String

func (e MLModelError) String() string

type MLModelErrorHandler

type MLModelErrorHandler = func(*MLModel, error)

MLModelErrorHandler handles The completion handler invoked when the load completes. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

  • [MLModel.LoadModelAssetConfigurationCompletionHandler]

type MLModelMetadataKey

type MLModelMetadataKey = string

MLModelMetadataKey is the set of keys the model uses to store values in its metadata dictionary.

See: https://developer.apple.com/documentation/CoreML/MLModelMetadataKey

var (
	// MLModelAuthorKey is key for the author of the model.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLModelMetadataKey/author
	MLModelAuthorKey MLModelMetadataKey
	// MLModelCreatorDefinedKey is key for the model creator’s custom metadata.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLModelMetadataKey/creatorDefinedKey
	MLModelCreatorDefinedKey MLModelMetadataKey
	// MLModelDescriptionKey is key for the overall description of the model.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLModelMetadataKey/description
	MLModelDescriptionKey MLModelMetadataKey
	// MLModelLicenseKey is key for the license of the model.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLModelMetadataKey/license
	MLModelLicenseKey MLModelMetadataKey
	// MLModelVersionStringKey is key for the version of the model.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLModelMetadataKey/versionString
	MLModelVersionStringKey MLModelMetadataKey
)

type MLModelStructure

type MLModelStructure struct {
	objectivec.Object
}

A class representing the structure of a model.

Overview

Model structures

See: https://developer.apple.com/documentation/CoreML/MLModelStructure-c.class

func MLModelStructureFromID

func MLModelStructureFromID(id objc.ID) MLModelStructure

MLModelStructureFromID constructs a MLModelStructure from an objc.ID.

A class representing the structure of a model.

func NewMLModelStructure

func NewMLModelStructure() MLModelStructure

NewMLModelStructure creates a new MLModelStructure instance.

func (MLModelStructure) Autorelease

func (m MLModelStructure) Autorelease() MLModelStructure

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructure) Init

Init initializes the instance.

func (MLModelStructure) NeuralNetwork

If the model is of NeuralNetwork type then it is the structure of the NeuralNetwork otherwise `nil`.

See: https://developer.apple.com/documentation/CoreML/MLModelStructure-c.class/neuralNetwork

func (MLModelStructure) Pipeline

If the model is of Pipeline type then it is the structure of the Pipeline otherwise `nil`.

See: https://developer.apple.com/documentation/CoreML/MLModelStructure-c.class/pipeline

func (MLModelStructure) Program

If the model is of ML Program type then it is the structure of the ML Program otherwise `nil`.

See: https://developer.apple.com/documentation/CoreML/MLModelStructure-c.class/program

type MLModelStructureClass

type MLModelStructureClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureClass

func GetMLModelStructureClass() MLModelStructureClass

GetMLModelStructureClass returns the class object for MLModelStructure.

func (MLModelStructureClass) Alloc

Alloc allocates memory for a new instance of the class.

func (MLModelStructureClass) LoadContentsOfURL

func (mc MLModelStructureClass) LoadContentsOfURL(ctx context.Context, url foundation.INSURL) (*MLModelStructure, error)

LoadContentsOfURL is a synchronous wrapper around [MLModelStructure.LoadContentsOfURLCompletionHandler]. It blocks until the completion handler fires or the context is cancelled.

func (MLModelStructureClass) LoadContentsOfURLCompletionHandler

func (_MLModelStructureClass MLModelStructureClass) LoadContentsOfURLCompletionHandler(url foundation.INSURL, handler MLModelStructureErrorHandler)

Construct the model structure asynchronously given the location of its on-disk representation.

url: The location of its on-disk representation (.mlmodelc directory).

handler: When the model structure is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLModelStructure instance or NSError object.

See: https://developer.apple.com/documentation/CoreML/MLModelStructure-c.class/loadContentsOfURL:completionHandler:

func (MLModelStructureClass) LoadModelAsset

func (mc MLModelStructureClass) LoadModelAsset(ctx context.Context, asset IMLModelAsset) (*MLModelStructure, error)

LoadModelAsset is a synchronous wrapper around [MLModelStructure.LoadModelAssetCompletionHandler]. It blocks until the completion handler fires or the context is cancelled.

func (MLModelStructureClass) LoadModelAssetCompletionHandler

func (_MLModelStructureClass MLModelStructureClass) LoadModelAssetCompletionHandler(asset IMLModelAsset, handler MLModelStructureErrorHandler)

Construct the model structure asynchronously given the model asset.

asset: The model asset.

handler: When the model structure is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLModelStructure instance or NSError object.

See: https://developer.apple.com/documentation/CoreML/MLModelStructure-c.class/loadModelAsset:completionHandler:

type MLModelStructureErrorHandler

type MLModelStructureErrorHandler = func(*MLModelStructure, error)

MLModelStructureErrorHandler handles When the model structure is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLModelStructure instance or NSError object. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

  • [MLModelStructure.LoadContentsOfURLCompletionHandler]
  • [MLModelStructure.LoadModelAssetCompletionHandler]

type MLModelStructureNeuralNetwork

type MLModelStructureNeuralNetwork struct {
	objectivec.Object
}

A class representing the structure of a NeuralNetwork model.

Accessing the layers

See: https://developer.apple.com/documentation/CoreML/MLModelStructureNeuralNetwork

func MLModelStructureNeuralNetworkFromID

func MLModelStructureNeuralNetworkFromID(id objc.ID) MLModelStructureNeuralNetwork

MLModelStructureNeuralNetworkFromID constructs a MLModelStructureNeuralNetwork from an objc.ID.

A class representing the structure of a NeuralNetwork model.

func NewMLModelStructureNeuralNetwork

func NewMLModelStructureNeuralNetwork() MLModelStructureNeuralNetwork

NewMLModelStructureNeuralNetwork creates a new MLModelStructureNeuralNetwork instance.

func (MLModelStructureNeuralNetwork) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureNeuralNetwork) Init

Init initializes the instance.

func (MLModelStructureNeuralNetwork) Layers

The topologically sorted layers in the NeuralNetwork.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureNeuralNetwork/layers

type MLModelStructureNeuralNetworkClass

type MLModelStructureNeuralNetworkClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureNeuralNetworkClass

func GetMLModelStructureNeuralNetworkClass() MLModelStructureNeuralNetworkClass

GetMLModelStructureNeuralNetworkClass returns the class object for MLModelStructureNeuralNetwork.

func (MLModelStructureNeuralNetworkClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureNeuralNetworkLayer

type MLModelStructureNeuralNetworkLayer struct {
	objectivec.Object
}

A class representing a layer in a NeuralNetwork.

Accessing the network layer properties

See: https://developer.apple.com/documentation/CoreML/MLModelStructureNeuralNetworkLayer

func MLModelStructureNeuralNetworkLayerFromID

func MLModelStructureNeuralNetworkLayerFromID(id objc.ID) MLModelStructureNeuralNetworkLayer

MLModelStructureNeuralNetworkLayerFromID constructs a MLModelStructureNeuralNetworkLayer from an objc.ID.

A class representing a layer in a NeuralNetwork.

func NewMLModelStructureNeuralNetworkLayer

func NewMLModelStructureNeuralNetworkLayer() MLModelStructureNeuralNetworkLayer

NewMLModelStructureNeuralNetworkLayer creates a new MLModelStructureNeuralNetworkLayer instance.

func (MLModelStructureNeuralNetworkLayer) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureNeuralNetworkLayer) Init

Init initializes the instance.

func (MLModelStructureNeuralNetworkLayer) Type

The type of the layer, e,g, “elementwise”, “pooling”, etc.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureNeuralNetworkLayer/type

type MLModelStructureNeuralNetworkLayerClass

type MLModelStructureNeuralNetworkLayerClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureNeuralNetworkLayerClass

func GetMLModelStructureNeuralNetworkLayerClass() MLModelStructureNeuralNetworkLayerClass

GetMLModelStructureNeuralNetworkLayerClass returns the class object for MLModelStructureNeuralNetworkLayer.

func (MLModelStructureNeuralNetworkLayerClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructurePipeline

type MLModelStructurePipeline struct {
	objectivec.Object
}

A class representing the structure of a Pipeline model.

Accessing the models and model names

See: https://developer.apple.com/documentation/CoreML/MLModelStructurePipeline

func MLModelStructurePipelineFromID

func MLModelStructurePipelineFromID(id objc.ID) MLModelStructurePipeline

MLModelStructurePipelineFromID constructs a MLModelStructurePipeline from an objc.ID.

A class representing the structure of a Pipeline model.

func NewMLModelStructurePipeline

func NewMLModelStructurePipeline() MLModelStructurePipeline

NewMLModelStructurePipeline creates a new MLModelStructurePipeline instance.

func (MLModelStructurePipeline) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructurePipeline) Init

Init initializes the instance.

func (MLModelStructurePipeline) SubModelNames

func (m MLModelStructurePipeline) SubModelNames() []string

The names of the sub models in the pipeline.

See: https://developer.apple.com/documentation/CoreML/MLModelStructurePipeline/subModelNames

func (MLModelStructurePipeline) SubModels

The structure of the sub models in the pipeline.

See: https://developer.apple.com/documentation/CoreML/MLModelStructurePipeline/subModels

type MLModelStructurePipelineClass

type MLModelStructurePipelineClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructurePipelineClass

func GetMLModelStructurePipelineClass() MLModelStructurePipelineClass

GetMLModelStructurePipelineClass returns the class object for MLModelStructurePipeline.

func (MLModelStructurePipelineClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureProgram

type MLModelStructureProgram struct {
	objectivec.Object
}

A class representing the structure of an ML Program model.

Accessing the program functions

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgram

func MLModelStructureProgramFromID

func MLModelStructureProgramFromID(id objc.ID) MLModelStructureProgram

MLModelStructureProgramFromID constructs a MLModelStructureProgram from an objc.ID.

A class representing the structure of an ML Program model.

func NewMLModelStructureProgram

func NewMLModelStructureProgram() MLModelStructureProgram

NewMLModelStructureProgram creates a new MLModelStructureProgram instance.

func (MLModelStructureProgram) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureProgram) Functions

The functions in the program.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgram/functions

func (MLModelStructureProgram) Init

Init initializes the instance.

type MLModelStructureProgramArgument

type MLModelStructureProgramArgument struct {
	objectivec.Object
}

A class representing an argument in the Program.

Accessing the bindings

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramArgument

func MLModelStructureProgramArgumentFromID

func MLModelStructureProgramArgumentFromID(id objc.ID) MLModelStructureProgramArgument

MLModelStructureProgramArgumentFromID constructs a MLModelStructureProgramArgument from an objc.ID.

A class representing an argument in the Program.

func NewMLModelStructureProgramArgument

func NewMLModelStructureProgramArgument() MLModelStructureProgramArgument

NewMLModelStructureProgramArgument creates a new MLModelStructureProgramArgument instance.

func (MLModelStructureProgramArgument) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureProgramArgument) Init

Init initializes the instance.

type MLModelStructureProgramArgumentClass

type MLModelStructureProgramArgumentClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureProgramArgumentClass

func GetMLModelStructureProgramArgumentClass() MLModelStructureProgramArgumentClass

GetMLModelStructureProgramArgumentClass returns the class object for MLModelStructureProgramArgument.

func (MLModelStructureProgramArgumentClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureProgramBinding

type MLModelStructureProgramBinding struct {
	objectivec.Object
}

A class representing a binding in the Program

Overview

A Binding is either a previously defined name of a variable or a constant value in the Program.

Accessing the program binding properties

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramBinding

func MLModelStructureProgramBindingFromID

func MLModelStructureProgramBindingFromID(id objc.ID) MLModelStructureProgramBinding

MLModelStructureProgramBindingFromID constructs a MLModelStructureProgramBinding from an objc.ID.

A class representing a binding in the Program

func NewMLModelStructureProgramBinding

func NewMLModelStructureProgramBinding() MLModelStructureProgramBinding

NewMLModelStructureProgramBinding creates a new MLModelStructureProgramBinding instance.

func (MLModelStructureProgramBinding) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureProgramBinding) Init

Init initializes the instance.

func (MLModelStructureProgramBinding) Name

The name of the variable in the Program.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramBinding/name

func (MLModelStructureProgramBinding) Value

The compile time constant value in the Program.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramBinding/value

type MLModelStructureProgramBindingClass

type MLModelStructureProgramBindingClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureProgramBindingClass

func GetMLModelStructureProgramBindingClass() MLModelStructureProgramBindingClass

GetMLModelStructureProgramBindingClass returns the class object for MLModelStructureProgramBinding.

func (MLModelStructureProgramBindingClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureProgramBlock

type MLModelStructureProgramBlock struct {
	objectivec.Object
}

A class representing a block in the Program.

Accessing the program block properties

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramBlock

func MLModelStructureProgramBlockFromID

func MLModelStructureProgramBlockFromID(id objc.ID) MLModelStructureProgramBlock

MLModelStructureProgramBlockFromID constructs a MLModelStructureProgramBlock from an objc.ID.

A class representing a block in the Program.

func NewMLModelStructureProgramBlock

func NewMLModelStructureProgramBlock() MLModelStructureProgramBlock

NewMLModelStructureProgramBlock creates a new MLModelStructureProgramBlock instance.

func (MLModelStructureProgramBlock) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureProgramBlock) Init

Init initializes the instance.

func (MLModelStructureProgramBlock) Operations

The list of topologically sorted operations in the block.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramBlock/operations

type MLModelStructureProgramBlockClass

type MLModelStructureProgramBlockClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureProgramBlockClass

func GetMLModelStructureProgramBlockClass() MLModelStructureProgramBlockClass

GetMLModelStructureProgramBlockClass returns the class object for MLModelStructureProgramBlock.

func (MLModelStructureProgramBlockClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureProgramClass

type MLModelStructureProgramClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureProgramClass

func GetMLModelStructureProgramClass() MLModelStructureProgramClass

GetMLModelStructureProgramClass returns the class object for MLModelStructureProgram.

func (MLModelStructureProgramClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureProgramFunction

type MLModelStructureProgramFunction struct {
	objectivec.Object
}

A class representing a function in the Program.

Accessing the program function properties

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramFunction

func MLModelStructureProgramFunctionFromID

func MLModelStructureProgramFunctionFromID(id objc.ID) MLModelStructureProgramFunction

MLModelStructureProgramFunctionFromID constructs a MLModelStructureProgramFunction from an objc.ID.

A class representing a function in the Program.

func NewMLModelStructureProgramFunction

func NewMLModelStructureProgramFunction() MLModelStructureProgramFunction

NewMLModelStructureProgramFunction creates a new MLModelStructureProgramFunction instance.

func (MLModelStructureProgramFunction) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureProgramFunction) Init

Init initializes the instance.

type MLModelStructureProgramFunctionClass

type MLModelStructureProgramFunctionClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureProgramFunctionClass

func GetMLModelStructureProgramFunctionClass() MLModelStructureProgramFunctionClass

GetMLModelStructureProgramFunctionClass returns the class object for MLModelStructureProgramFunction.

func (MLModelStructureProgramFunctionClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureProgramNamedValueType

type MLModelStructureProgramNamedValueType struct {
	objectivec.Object
}

A class representing a named value type in a Program.

Accessing the value type properties

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramNamedValueType

func MLModelStructureProgramNamedValueTypeFromID

func MLModelStructureProgramNamedValueTypeFromID(id objc.ID) MLModelStructureProgramNamedValueType

MLModelStructureProgramNamedValueTypeFromID constructs a MLModelStructureProgramNamedValueType from an objc.ID.

A class representing a named value type in a Program.

func NewMLModelStructureProgramNamedValueType

func NewMLModelStructureProgramNamedValueType() MLModelStructureProgramNamedValueType

NewMLModelStructureProgramNamedValueType creates a new MLModelStructureProgramNamedValueType instance.

func (MLModelStructureProgramNamedValueType) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureProgramNamedValueType) Init

Init initializes the instance.

func (MLModelStructureProgramNamedValueType) Name

The name of the parameter.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramNamedValueType/name

type MLModelStructureProgramNamedValueTypeClass

type MLModelStructureProgramNamedValueTypeClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureProgramNamedValueTypeClass

func GetMLModelStructureProgramNamedValueTypeClass() MLModelStructureProgramNamedValueTypeClass

GetMLModelStructureProgramNamedValueTypeClass returns the class object for MLModelStructureProgramNamedValueType.

func (MLModelStructureProgramNamedValueTypeClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureProgramOperation

type MLModelStructureProgramOperation struct {
	objectivec.Object
}

A class representing an Operation in a Program.

Accessing the program operation properties

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramOperation

func MLModelStructureProgramOperationFromID

func MLModelStructureProgramOperationFromID(id objc.ID) MLModelStructureProgramOperation

MLModelStructureProgramOperationFromID constructs a MLModelStructureProgramOperation from an objc.ID.

A class representing an Operation in a Program.

func NewMLModelStructureProgramOperation

func NewMLModelStructureProgramOperation() MLModelStructureProgramOperation

NewMLModelStructureProgramOperation creates a new MLModelStructureProgramOperation instance.

func (MLModelStructureProgramOperation) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureProgramOperation) Blocks

Nested blocks for loops and conditionals, e.g., a conditional block will have two entries here.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramOperation/blocks

func (MLModelStructureProgramOperation) Init

Init initializes the instance.

func (MLModelStructureProgramOperation) Inputs

The arguments to the Operation.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramOperation/inputs

func (MLModelStructureProgramOperation) OperatorName

func (m MLModelStructureProgramOperation) OperatorName() string

The name of the operator, e.g., “conv”, “pool”, “softmax”, etc.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramOperation/operatorName

type MLModelStructureProgramOperationClass

type MLModelStructureProgramOperationClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureProgramOperationClass

func GetMLModelStructureProgramOperationClass() MLModelStructureProgramOperationClass

GetMLModelStructureProgramOperationClass returns the class object for MLModelStructureProgramOperation.

func (MLModelStructureProgramOperationClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureProgramValue

type MLModelStructureProgramValue struct {
	objectivec.Object
}

A class representing a constant value in the Program.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramValue

func MLModelStructureProgramValueFromID

func MLModelStructureProgramValueFromID(id objc.ID) MLModelStructureProgramValue

MLModelStructureProgramValueFromID constructs a MLModelStructureProgramValue from an objc.ID.

A class representing a constant value in the Program.

func NewMLModelStructureProgramValue

func NewMLModelStructureProgramValue() MLModelStructureProgramValue

NewMLModelStructureProgramValue creates a new MLModelStructureProgramValue instance.

func (MLModelStructureProgramValue) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureProgramValue) Init

Init initializes the instance.

type MLModelStructureProgramValueClass

type MLModelStructureProgramValueClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureProgramValueClass

func GetMLModelStructureProgramValueClass() MLModelStructureProgramValueClass

GetMLModelStructureProgramValueClass returns the class object for MLModelStructureProgramValue.

func (MLModelStructureProgramValueClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLModelStructureProgramValueType

type MLModelStructureProgramValueType struct {
	objectivec.Object
}

A class representing the type of a value or a variable in the Program.

See: https://developer.apple.com/documentation/CoreML/MLModelStructureProgramValueType

func MLModelStructureProgramValueTypeFromID

func MLModelStructureProgramValueTypeFromID(id objc.ID) MLModelStructureProgramValueType

MLModelStructureProgramValueTypeFromID constructs a MLModelStructureProgramValueType from an objc.ID.

A class representing the type of a value or a variable in the Program.

func NewMLModelStructureProgramValueType

func NewMLModelStructureProgramValueType() MLModelStructureProgramValueType

NewMLModelStructureProgramValueType creates a new MLModelStructureProgramValueType instance.

func (MLModelStructureProgramValueType) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLModelStructureProgramValueType) Init

Init initializes the instance.

type MLModelStructureProgramValueTypeClass

type MLModelStructureProgramValueTypeClass struct {
	// contains filtered or unexported fields
}

func GetMLModelStructureProgramValueTypeClass

func GetMLModelStructureProgramValueTypeClass() MLModelStructureProgramValueTypeClass

GetMLModelStructureProgramValueTypeClass returns the class object for MLModelStructureProgramValueType.

func (MLModelStructureProgramValueTypeClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLMultiArray

type MLMultiArray struct {
	objectivec.Object
}

A machine learning collection type that stores numeric values in an array with multiple dimensions.

Overview

A multidimensional array, or , is one of the underlying types of an MLFeatureValue that stores numeric values in multiple dimensions. All elements in an MLMultiArray instance are one of the same type, and one of the types that MLMultiArrayDataType defines:

MLMultiArrayDataType.int32: 32-bit integer MLMultiArrayDataType.float16: 16-bit floating point number MLMultiArrayDataType.float32: 32-bit floating point number (also known as float) float64: 64-bit floating point number (also known as `double` in Swift or MLMultiArrayDataTypeDouble in Objective-C)

Each dimension in a multiarray is typically significant or meaningful. For example, a model could have an input that accepts images as a multiarray of pixels with three dimensions, C x H x W. The first dimension, ,_ _represents the number of color channels, and the second and third dimensions, and , represent the image’s height and width, respectively. The number of dimensions and size of each dimension define the multiarray’s .

The MLMultiArray.Shape property is an integer array that has an element for each dimension in the multiarray. Each element in MLMultiArray.Shape defines the size of the corresponding dimension. To inspect the shape and constraints of a model’s multiarray input or output feature:

- Access the model’s [ModelDescription] property. - Find the multiarray input or output feature in the model description’s MLMultiArray.InputDescriptionsByName or MLMultiArray.OutputDescriptionsByName property, respectively. - Access the feature description’s [MultiArrayConstraint] property. - Inspect the multiarray constraint’s MLMultiArray.Shape and MLMultiArray.ShapeConstraint.

Creating a multiarray

Inspecting a multiarray

  • MLMultiArray.Count: The total number of elements in the multiarray.
  • MLMultiArray.DataType: The underlying type of the multiarray.
  • MLMultiArray.Shape: The multiarray’s multidimensional shape as a number array in which each element’s value is the size of the corresponding dimension.
  • MLMultiArray.Strides: A number array in which each element is the number of memory locations that span the length of the corresponding dimension.

Transfering the contents

Accessing a multiarray’s elements

See: https://developer.apple.com/documentation/CoreML/MLMultiArray

func MLMultiArrayFromID

func MLMultiArrayFromID(id objc.ID) MLMultiArray

MLMultiArrayFromID constructs a MLMultiArray from an objc.ID.

A machine learning collection type that stores numeric values in an array with multiple dimensions.

func NewMLMultiArray

func NewMLMultiArray() MLMultiArray

NewMLMultiArray creates a new MLMultiArray instance.

func NewMultiArrayByConcatenatingMultiArraysAlongAxisDataType

func NewMultiArrayByConcatenatingMultiArraysAlongAxisDataType(multiArrays []MLMultiArray, axis int, dataType MLMultiArrayDataType) MLMultiArray

Merges an array of multiarrays into one multiarray along an axis.

multiArrays: An MLMultiArray array.

axis: A zero-based axis number the instances in `multiArray` merge along.

dataType: An MLMultiArrayDataType instance that represents the underlying type of all the instances in `multiArrays`. // MLMultiArrayDataType: https://developer.apple.com/documentation/CoreML/MLMultiArrayDataType

Discussion

All multiarray instances in `multiArrays` must have:

- The same data type - The same number of dimensions - The same size for each corresponding dimension, except for the concatenation axis

For example, this code concatenates two multiarrays along their first dimension:

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/init(byConcatenatingMultiArrays:alongAxis:dataType:)

func NewMultiArrayWithPixelBufferShape

func NewMultiArrayWithPixelBufferShape(pixelBuffer corevideo.CVImageBufferRef, shape []foundation.NSNumber) MLMultiArray

Creates a multiarray sharing the surface of a pixel buffer.

pixelBuffer: The pixel buffer owned by the instance.

shape: The shape of the MLMultiArray. The last dimension of `shape` must match the pixel buffer’s width. The product of the rest of the dimensions must match the height.

Discussion

Use this initializer to create an IOSurface-backed MLMultiArray that reduces the inference latency by avoiding the buffer copy to and from some compute units.

The instance will own the pixel buffer and release it on the deallocation.

The pixel buffer’s pixel format type must be kCVPixelFormatType_OneComponent16Half. The MLMultiArray data type is MLMultiArrayDataType.float16.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/init(pixelBuffer:shape:)

func NewMultiArrayWithShapeDataTypeError

func NewMultiArrayWithShapeDataTypeError(shape []foundation.NSNumber, dataType MLMultiArrayDataType) (MLMultiArray, error)

Creates a multidimensional array with a shape and type.

shape: An integer array that has an element for each dimension in a multiarray that represents its length.

dataType: An element type defined by MLMultiArrayDataType. // MLMultiArrayDataType: https://developer.apple.com/documentation/CoreML/MLMultiArrayDataType

Discussion

This method allocates a contiguous region of memory for the multiarray’s shape. You must set the contents of memory. The multiarray frees the memory in its deinitializer (Swift) or dealloc method (Objective-C).

The following code creates a 3 x 3 multiarray and sets its contents to the value 3.14159.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/init(shape:dataType:)

func (MLMultiArray) Autorelease

func (m MLMultiArray) Autorelease() MLMultiArray

Autorelease adds the receiver to the current autorelease pool.

func (MLMultiArray) Count

func (m MLMultiArray) Count() int

The total number of elements in the multiarray.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/count

func (MLMultiArray) DataType

func (m MLMultiArray) DataType() MLMultiArrayDataType

The underlying type of the multiarray.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/dataType

func (MLMultiArray) EncodeWithCoder

func (m MLMultiArray) EncodeWithCoder(coder foundation.INSCoder)

func (MLMultiArray) Init

func (m MLMultiArray) Init() MLMultiArray

Init initializes the instance.

func (MLMultiArray) InitWithDataPointerShapeDataTypeStridesDeallocatorError

func (m MLMultiArray) InitWithDataPointerShapeDataTypeStridesDeallocatorError(dataPointer unsafe.Pointer, shape []foundation.NSNumber, dataType MLMultiArrayDataType, strides []foundation.NSNumber, deallocator func(unsafe.Pointer)) (MLMultiArray, error)

Creates a multiarray from a data pointer.

dataPointer: A pointer to data in memory.

shape: An integer array with an element for each dimension. An element represents the size of the corresponding dimension.

dataType: An MLMultiArrayDataType instance that represents the pointer’s data type. // MLMultiArrayDataType: https://developer.apple.com/documentation/CoreML/MLMultiArrayDataType

strides: An integer array with an element for each dimension. An element represents the number of memory locations that span the length of the corresponding dimension.

deallocator: In Swift, a closure the multiarray calls in its deinitializer. In Objective-C, a block the multiarray calls in its [dealloc] method. // [dealloc]: https://developer.apple.com/documentation/ObjectiveC/NSObject-swift.class/dealloc

Discussion

The caller is responsible for freeing the memory the `dataPointer` points to, by providing a `deallocator` closure.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/init(dataPointer:shape:dataType:strides:deallocator:)

func (MLMultiArray) InitWithPixelBufferShape

func (m MLMultiArray) InitWithPixelBufferShape(pixelBuffer corevideo.CVImageBufferRef, shape []foundation.NSNumber) MLMultiArray

Creates a multiarray sharing the surface of a pixel buffer.

pixelBuffer: The pixel buffer owned by the instance.

shape: The shape of the MLMultiArray. The last dimension of `shape` must match the pixel buffer’s width. The product of the rest of the dimensions must match the height.

Discussion

Use this initializer to create an IOSurface-backed MLMultiArray that reduces the inference latency by avoiding the buffer copy to and from some compute units.

The instance will own the pixel buffer and release it on the deallocation.

The pixel buffer’s pixel format type must be kCVPixelFormatType_OneComponent16Half. The MLMultiArray data type is MLMultiArrayDataType.float16.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/init(pixelBuffer:shape:)

func (MLMultiArray) InitWithShapeDataTypeError

func (m MLMultiArray) InitWithShapeDataTypeError(shape []foundation.NSNumber, dataType MLMultiArrayDataType) (MLMultiArray, error)

Creates a multidimensional array with a shape and type.

shape: An integer array that has an element for each dimension in a multiarray that represents its length.

dataType: An element type defined by MLMultiArrayDataType. // MLMultiArrayDataType: https://developer.apple.com/documentation/CoreML/MLMultiArrayDataType

Discussion

This method allocates a contiguous region of memory for the multiarray’s shape. You must set the contents of memory. The multiarray frees the memory in its deinitializer (Swift) or dealloc method (Objective-C).

The following code creates a 3 x 3 multiarray and sets its contents to the value 3.14159.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/init(shape:dataType:)

func (MLMultiArray) InputDescriptionsByName

func (m MLMultiArray) InputDescriptionsByName() IMLFeatureDescription

A dictionary of input feature descriptions, which the model keys by the input’s name.

See: https://developer.apple.com/documentation/coreml/mlmodeldescription/inputdescriptionsbyname

func (MLMultiArray) ModelDescription

func (m MLMultiArray) ModelDescription() IMLModelDescription

Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.

See: https://developer.apple.com/documentation/coreml/mlmodel/modeldescription

func (MLMultiArray) MultiArrayConstraint

func (m MLMultiArray) MultiArrayConstraint() IMLMultiArrayConstraint

The constraints on a multidimensional array feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/multiarrayconstraint

func (MLMultiArray) OutputDescriptionsByName

func (m MLMultiArray) OutputDescriptionsByName() IMLFeatureDescription

A dictionary of output feature descriptions, which the model keys by the output’s name.

See: https://developer.apple.com/documentation/coreml/mlmodeldescription/outputdescriptionsbyname

func (MLMultiArray) PixelBuffer

func (m MLMultiArray) PixelBuffer() corevideo.CVImageBufferRef

A reference to the multiarray’s underlying pixel buffer.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/pixelBuffer

func (MLMultiArray) SetInputDescriptionsByName

func (m MLMultiArray) SetInputDescriptionsByName(value IMLFeatureDescription)

func (MLMultiArray) SetModelDescription

func (m MLMultiArray) SetModelDescription(value IMLModelDescription)

func (MLMultiArray) SetMultiArrayConstraint

func (m MLMultiArray) SetMultiArrayConstraint(value IMLMultiArrayConstraint)

func (MLMultiArray) SetOutputDescriptionsByName

func (m MLMultiArray) SetOutputDescriptionsByName(value IMLFeatureDescription)

func (MLMultiArray) SetShapeConstraint

func (m MLMultiArray) SetShapeConstraint(value IMLMultiArrayShapeConstraint)

func (MLMultiArray) Shape

func (m MLMultiArray) Shape() []foundation.NSNumber

The multiarray’s multidimensional shape as a number array in which each element’s value is the size of the corresponding dimension.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/shape

func (MLMultiArray) ShapeConstraint

func (m MLMultiArray) ShapeConstraint() IMLMultiArrayShapeConstraint

The constraint on the shape of the multiarray.

See: https://developer.apple.com/documentation/coreml/mlmultiarrayconstraint/shapeconstraint

func (MLMultiArray) Strides

func (m MLMultiArray) Strides() []foundation.NSNumber

A number array in which each element is the number of memory locations that span the length of the corresponding dimension.

Discussion

See subscript(_:) and subscript(_:) for code examples that use `strides`.

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/strides

func (MLMultiArray) TransferToMultiArray

func (m MLMultiArray) TransferToMultiArray(destinationMultiArray IMLMultiArray)

Transfer the contents to the destination multi-array.

destinationMultiArray: The transfer destination.

Discussion

Numeric data will be up or down casted as needed. It can transfer to a multi-array with different layout (strides).

See: https://developer.apple.com/documentation/CoreML/MLMultiArray/transfer(to:)

type MLMultiArrayClass

type MLMultiArrayClass struct {
	// contains filtered or unexported fields
}

func GetMLMultiArrayClass

func GetMLMultiArrayClass() MLMultiArrayClass

GetMLMultiArrayClass returns the class object for MLMultiArray.

func (MLMultiArrayClass) Alloc

func (mc MLMultiArrayClass) Alloc() MLMultiArray

Alloc allocates memory for a new instance of the class.

type MLMultiArrayConstraint

type MLMultiArrayConstraint struct {
	objectivec.Object
}

The shape and data type constraints for a multidimensional array feature.

Accessing the Constraints

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayConstraint

func MLMultiArrayConstraintFromID

func MLMultiArrayConstraintFromID(id objc.ID) MLMultiArrayConstraint

MLMultiArrayConstraintFromID constructs a MLMultiArrayConstraint from an objc.ID.

The shape and data type constraints for a multidimensional array feature.

func NewMLMultiArrayConstraint

func NewMLMultiArrayConstraint() MLMultiArrayConstraint

NewMLMultiArrayConstraint creates a new MLMultiArrayConstraint instance.

func (MLMultiArrayConstraint) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLMultiArrayConstraint) DataType

The type for the multi array.

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayConstraint/dataType

func (MLMultiArrayConstraint) DictionaryConstraint

func (m MLMultiArrayConstraint) DictionaryConstraint() IMLDictionaryConstraint

The constraint for a dictionary feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/dictionaryconstraint

func (MLMultiArrayConstraint) EncodeWithCoder

func (m MLMultiArrayConstraint) EncodeWithCoder(coder foundation.INSCoder)

func (MLMultiArrayConstraint) ImageConstraint

func (m MLMultiArrayConstraint) ImageConstraint() IMLImageConstraint

The size and format constraints for an image feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/imageconstraint

func (MLMultiArrayConstraint) Init

Init initializes the instance.

func (MLMultiArrayConstraint) MultiArrayConstraint

func (m MLMultiArrayConstraint) MultiArrayConstraint() IMLMultiArrayConstraint

The constraints on a multidimensional array feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/multiarrayconstraint

func (MLMultiArrayConstraint) SequenceConstraint

func (m MLMultiArrayConstraint) SequenceConstraint() IMLSequenceConstraint

The constraints for a sequence feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/sequenceconstraint

func (MLMultiArrayConstraint) SetDictionaryConstraint

func (m MLMultiArrayConstraint) SetDictionaryConstraint(value IMLDictionaryConstraint)

func (MLMultiArrayConstraint) SetImageConstraint

func (m MLMultiArrayConstraint) SetImageConstraint(value IMLImageConstraint)

func (MLMultiArrayConstraint) SetMultiArrayConstraint

func (m MLMultiArrayConstraint) SetMultiArrayConstraint(value IMLMultiArrayConstraint)

func (MLMultiArrayConstraint) SetSequenceConstraint

func (m MLMultiArrayConstraint) SetSequenceConstraint(value IMLSequenceConstraint)

func (MLMultiArrayConstraint) SetStateConstraint

func (m MLMultiArrayConstraint) SetStateConstraint(value IMLStateConstraint)

func (MLMultiArrayConstraint) Shape

The shape of the multi array.

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayConstraint/shape

func (MLMultiArrayConstraint) ShapeConstraint

The constraint on the shape of the multiarray.

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayConstraint/shapeConstraint

func (MLMultiArrayConstraint) StateConstraint

func (m MLMultiArrayConstraint) StateConstraint() IMLStateConstraint

The state feature value constraint.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/stateconstraint

type MLMultiArrayConstraintClass

type MLMultiArrayConstraintClass struct {
	// contains filtered or unexported fields
}

func GetMLMultiArrayConstraintClass

func GetMLMultiArrayConstraintClass() MLMultiArrayConstraintClass

GetMLMultiArrayConstraintClass returns the class object for MLMultiArrayConstraint.

func (MLMultiArrayConstraintClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLMultiArrayDataType

type MLMultiArrayDataType int

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayDataType

const (
	// MLMultiArrayDataTypeDouble: Designates the multiarray’s elements as doubles.
	MLMultiArrayDataTypeDouble MLMultiArrayDataType = 65536
	// MLMultiArrayDataTypeFloat16: Designates the multiarray’s elements as 16-bit floats.
	MLMultiArrayDataTypeFloat16 MLMultiArrayDataType = 65536
	// MLMultiArrayDataTypeFloat32: Designates the multiarray’s elements as 32-bit floats.
	MLMultiArrayDataTypeFloat32 MLMultiArrayDataType = 65536
	// MLMultiArrayDataTypeInt32: Designates the multiarray’s elements as 32-bit integers.
	MLMultiArrayDataTypeInt32 MLMultiArrayDataType = 131072
)

func (MLMultiArrayDataType) String

func (e MLMultiArrayDataType) String() string

type MLMultiArrayShapeConstraint

type MLMultiArrayShapeConstraint struct {
	objectivec.Object
}

The lists of shapes or ranges of shapes that constrain a multiarray feature.

Accessing the Constraints

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayShapeConstraint

func MLMultiArrayShapeConstraintFromID

func MLMultiArrayShapeConstraintFromID(id objc.ID) MLMultiArrayShapeConstraint

MLMultiArrayShapeConstraintFromID constructs a MLMultiArrayShapeConstraint from an objc.ID.

The lists of shapes or ranges of shapes that constrain a multiarray feature.

func NewMLMultiArrayShapeConstraint

func NewMLMultiArrayShapeConstraint() MLMultiArrayShapeConstraint

NewMLMultiArrayShapeConstraint creates a new MLMultiArrayShapeConstraint instance.

func (MLMultiArrayShapeConstraint) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLMultiArrayShapeConstraint) DataType

The type for the multi array.

See: https://developer.apple.com/documentation/coreml/mlmultiarrayconstraint/datatype

func (MLMultiArrayShapeConstraint) EncodeWithCoder

func (m MLMultiArrayShapeConstraint) EncodeWithCoder(coder foundation.INSCoder)

func (MLMultiArrayShapeConstraint) EnumeratedShapes

func (m MLMultiArrayShapeConstraint) EnumeratedShapes() []foundation.NSArray

Array of allowed shapes for a multiarray feature.

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayShapeConstraint/enumeratedShapes

func (MLMultiArrayShapeConstraint) Init

Init initializes the instance.

func (MLMultiArrayShapeConstraint) SetDataType

func (MLMultiArrayShapeConstraint) SetShape

func (MLMultiArrayShapeConstraint) SetShapeConstraint

func (m MLMultiArrayShapeConstraint) SetShapeConstraint(value IMLMultiArrayShapeConstraint)

func (MLMultiArrayShapeConstraint) Shape

The shape of the multi array.

See: https://developer.apple.com/documentation/coreml/mlmultiarrayconstraint/shape

func (MLMultiArrayShapeConstraint) ShapeConstraint

The constraint on the shape of the multiarray.

See: https://developer.apple.com/documentation/coreml/mlmultiarrayconstraint/shapeconstraint

func (MLMultiArrayShapeConstraint) SizeRangeForDimension

func (m MLMultiArrayShapeConstraint) SizeRangeForDimension() []foundation.NSValue

The allowable range for a dimention of the multiarray.

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayShapeConstraint/sizeRangeForDimension

type MLMultiArrayShapeConstraintClass

type MLMultiArrayShapeConstraintClass struct {
	// contains filtered or unexported fields
}

func GetMLMultiArrayShapeConstraintClass

func GetMLMultiArrayShapeConstraintClass() MLMultiArrayShapeConstraintClass

GetMLMultiArrayShapeConstraintClass returns the class object for MLMultiArrayShapeConstraint.

func (MLMultiArrayShapeConstraintClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLMultiArrayShapeConstraintType

type MLMultiArrayShapeConstraintType int

See: https://developer.apple.com/documentation/CoreML/MLMultiArrayShapeConstraintType

const (
	// MLMultiArrayShapeConstraintTypeEnumerated: The constraint is an array of allowed shapes.
	MLMultiArrayShapeConstraintTypeEnumerated MLMultiArrayShapeConstraintType = 2
	// MLMultiArrayShapeConstraintTypeRange: The constraint is a set of ranges allowed for the array shape.
	MLMultiArrayShapeConstraintTypeRange MLMultiArrayShapeConstraintType = 3
	// MLMultiArrayShapeConstraintTypeUnspecified: The constraint type is undefined.
	MLMultiArrayShapeConstraintTypeUnspecified MLMultiArrayShapeConstraintType = 1
)

func (MLMultiArrayShapeConstraintType) String

type MLNeuralEngineComputeDevice

type MLNeuralEngineComputeDevice struct {
	objectivec.Object
}

An object that represents a Neural Engine compute device.

Getting the Total Core Count

See: https://developer.apple.com/documentation/CoreML/MLNeuralEngineComputeDevice

func MLNeuralEngineComputeDeviceFromID

func MLNeuralEngineComputeDeviceFromID(id objc.ID) MLNeuralEngineComputeDevice

MLNeuralEngineComputeDeviceFromID constructs a MLNeuralEngineComputeDevice from an objc.ID.

An object that represents a Neural Engine compute device.

func NewMLNeuralEngineComputeDevice

func NewMLNeuralEngineComputeDevice() MLNeuralEngineComputeDevice

NewMLNeuralEngineComputeDevice creates a new MLNeuralEngineComputeDevice instance.

func (MLNeuralEngineComputeDevice) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLNeuralEngineComputeDevice) Init

Init initializes the instance.

func (MLNeuralEngineComputeDevice) TotalCoreCount

func (n MLNeuralEngineComputeDevice) TotalCoreCount() int

The total number of cores in the Neural Engine.

See: https://developer.apple.com/documentation/CoreML/MLNeuralEngineComputeDevice/totalCoreCount

type MLNeuralEngineComputeDeviceClass

type MLNeuralEngineComputeDeviceClass struct {
	// contains filtered or unexported fields
}

func GetMLNeuralEngineComputeDeviceClass

func GetMLNeuralEngineComputeDeviceClass() MLNeuralEngineComputeDeviceClass

GetMLNeuralEngineComputeDeviceClass returns the class object for MLNeuralEngineComputeDevice.

func (MLNeuralEngineComputeDeviceClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLNumericConstraint

type MLNumericConstraint struct {
	objectivec.Object
}

The value limitations of a number.

Numeric Constraints

See: https://developer.apple.com/documentation/CoreML/MLNumericConstraint

func MLNumericConstraintFromID

func MLNumericConstraintFromID(id objc.ID) MLNumericConstraint

MLNumericConstraintFromID constructs a MLNumericConstraint from an objc.ID.

The value limitations of a number.

func NewMLNumericConstraint

func NewMLNumericConstraint() MLNumericConstraint

NewMLNumericConstraint creates a new MLNumericConstraint instance.

func (MLNumericConstraint) Autorelease

func (n MLNumericConstraint) Autorelease() MLNumericConstraint

Autorelease adds the receiver to the current autorelease pool.

func (MLNumericConstraint) EncodeWithCoder

func (n MLNumericConstraint) EncodeWithCoder(coder foundation.INSCoder)

func (MLNumericConstraint) EnumeratedNumbers

func (n MLNumericConstraint) EnumeratedNumbers() foundation.INSSet

A set of the numbers allowed in this constraint.

See: https://developer.apple.com/documentation/CoreML/MLNumericConstraint/enumeratedNumbers

func (MLNumericConstraint) Init

Init initializes the instance.

func (MLNumericConstraint) MaxNumber

func (n MLNumericConstraint) MaxNumber() foundation.NSNumber

The largest numerical value allowed by this constraint.

See: https://developer.apple.com/documentation/CoreML/MLNumericConstraint/maxNumber

func (MLNumericConstraint) MinNumber

func (n MLNumericConstraint) MinNumber() foundation.NSNumber

The smallest numerical value allowed by this constraint.

See: https://developer.apple.com/documentation/CoreML/MLNumericConstraint/minNumber

func (MLNumericConstraint) NumericConstraint

func (n MLNumericConstraint) NumericConstraint() IMLNumericConstraint

The constraints of this paramter description value, if and only if the value is numerical.

See: https://developer.apple.com/documentation/coreml/mlparameterdescription/numericconstraint

func (MLNumericConstraint) SetNumericConstraint

func (n MLNumericConstraint) SetNumericConstraint(value IMLNumericConstraint)

type MLNumericConstraintClass

type MLNumericConstraintClass struct {
	// contains filtered or unexported fields
}

func GetMLNumericConstraintClass

func GetMLNumericConstraintClass() MLNumericConstraintClass

GetMLNumericConstraintClass returns the class object for MLNumericConstraint.

func (MLNumericConstraintClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLOptimizationHints

type MLOptimizationHints struct {
	objectivec.Object
}

MLOptimizationHints

Overview

An object to hold hints that CoreML could use for further optimization

Getting the reshape frequency

Getting the specialization strategy

See: https://developer.apple.com/documentation/CoreML/MLOptimizationHints-c.class

func MLOptimizationHintsFromID

func MLOptimizationHintsFromID(id objc.ID) MLOptimizationHints

MLOptimizationHintsFromID constructs a MLOptimizationHints from an objc.ID.

MLOptimizationHints

func NewMLOptimizationHints

func NewMLOptimizationHints() MLOptimizationHints

NewMLOptimizationHints creates a new MLOptimizationHints instance.

func (MLOptimizationHints) Autorelease

func (o MLOptimizationHints) Autorelease() MLOptimizationHints

Autorelease adds the receiver to the current autorelease pool.

func (MLOptimizationHints) EncodeWithCoder

func (o MLOptimizationHints) EncodeWithCoder(coder foundation.INSCoder)

func (MLOptimizationHints) Init

Init initializes the instance.

func (MLOptimizationHints) ReshapeFrequency

func (o MLOptimizationHints) ReshapeFrequency() MLReshapeFrequencyHint

The anticipated reshape frequency

Discussion

CoreML framework needs to reshape the model with new shapes for models with flexible input. Specify the anticipated reshape frequency (frequent or infrequent), so that the framework can optimize for fast shape switching or fast prediction on seen shapes.

The default value is frequent, which means CoreML tries to switch to new shapes as fast as possible

See: https://developer.apple.com/documentation/CoreML/MLOptimizationHints-c.class/reshapeFrequency

func (MLOptimizationHints) SetReshapeFrequency

func (o MLOptimizationHints) SetReshapeFrequency(value MLReshapeFrequencyHint)

func (MLOptimizationHints) SetSpecializationStrategy

func (o MLOptimizationHints) SetSpecializationStrategy(value MLSpecializationStrategy)

func (MLOptimizationHints) SpecializationStrategy

func (o MLOptimizationHints) SpecializationStrategy() MLSpecializationStrategy

Optimization strategy for the model specialization.

Discussion

Core ML segments the model’s compute graph and optimizes each segment for the target compute device. This process can affect the model loading time and the prediction latency.

Use this option to tailor the specialization strategy for your application.

See: https://developer.apple.com/documentation/CoreML/MLOptimizationHints-c.class/specializationStrategy

type MLOptimizationHintsClass

type MLOptimizationHintsClass struct {
	// contains filtered or unexported fields
}

func GetMLOptimizationHintsClass

func GetMLOptimizationHintsClass() MLOptimizationHintsClass

GetMLOptimizationHintsClass returns the class object for MLOptimizationHints.

func (MLOptimizationHintsClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLParameterDescription

type MLParameterDescription struct {
	objectivec.Object
}

A description of a model parameter that includes a default value and a constraint, if applicable.

Describing the model parameter

Constraining numeric values

See: https://developer.apple.com/documentation/CoreML/MLParameterDescription

func MLParameterDescriptionFromID

func MLParameterDescriptionFromID(id objc.ID) MLParameterDescription

MLParameterDescriptionFromID constructs a MLParameterDescription from an objc.ID.

A description of a model parameter that includes a default value and a constraint, if applicable.

func NewMLParameterDescription

func NewMLParameterDescription() MLParameterDescription

NewMLParameterDescription creates a new MLParameterDescription instance.

func (MLParameterDescription) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLParameterDescription) DefaultValue

func (p MLParameterDescription) DefaultValue() objectivec.IObject

The default value for the parameter.

See: https://developer.apple.com/documentation/CoreML/MLParameterDescription/defaultValue

func (MLParameterDescription) EncodeWithCoder

func (p MLParameterDescription) EncodeWithCoder(coder foundation.INSCoder)

func (MLParameterDescription) Init

Init initializes the instance.

func (MLParameterDescription) IsUpdatable

func (p MLParameterDescription) IsUpdatable() bool

A Boolean value that indicates whether you can update the model with additional training.

See: https://developer.apple.com/documentation/coreml/mlmodeldescription/isupdatable

func (MLParameterDescription) Key

The key for this parameter description value.

See: https://developer.apple.com/documentation/CoreML/MLParameterDescription/key

func (MLParameterDescription) NumericConstraint

func (p MLParameterDescription) NumericConstraint() IMLNumericConstraint

The constraints of this paramter description value, if and only if the value is numerical.

See: https://developer.apple.com/documentation/CoreML/MLParameterDescription/numericConstraint

func (MLParameterDescription) ParameterDescriptionsByKey

func (p MLParameterDescription) ParameterDescriptionsByKey() IMLParameterDescription

A dictionary of the descriptions for the model’s parameters.

See: https://developer.apple.com/documentation/coreml/mlmodeldescription/parameterdescriptionsbykey

func (MLParameterDescription) SetIsUpdatable

func (p MLParameterDescription) SetIsUpdatable(value bool)

func (MLParameterDescription) SetParameterDescriptionsByKey

func (p MLParameterDescription) SetParameterDescriptionsByKey(value IMLParameterDescription)

func (MLParameterDescription) SetTrainingInputDescriptionsByName

func (p MLParameterDescription) SetTrainingInputDescriptionsByName(value IMLFeatureDescription)

func (MLParameterDescription) TrainingInputDescriptionsByName

func (p MLParameterDescription) TrainingInputDescriptionsByName() IMLFeatureDescription

A dictionary of the training input feature descriptions, which the model keys by the input’s name.

See: https://developer.apple.com/documentation/coreml/mlmodeldescription/traininginputdescriptionsbyname

type MLParameterDescriptionClass

type MLParameterDescriptionClass struct {
	// contains filtered or unexported fields
}

func GetMLParameterDescriptionClass

func GetMLParameterDescriptionClass() MLParameterDescriptionClass

GetMLParameterDescriptionClass returns the class object for MLParameterDescription.

func (MLParameterDescriptionClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLParameterKey

type MLParameterKey struct {
	MLKey
}

The keys for the parameter dictionary in a model configuration or a model update context.

Overview

Use an MLParameterKey to retrieve a model’s parameter value using:

- The model’s [ParameterValueForKeyError] method - The MLParameterKey.Parameters dictionary of an MLModelConfiguration - The MLParameterKey.Parameters dictionary of an MLUpdateContext

Overriding model and layer parameters

To override a model’s default parameter values:

- Create an MLModelConfiguration instance. - Use an MLParameterKey for each parameter to set its value in the model configuration’s MLParameterKey.Parameters dictionary. - Create a new model instance using [ModelWithContentsOfURLConfigurationError] with your custom model configuration.

Configuring update parameters

To configure the update parameters for an MLUpdateTask:

- Create an MLModelConfiguration instance. - Use an MLParameterKey for each parameter to set its value in the model configuration’s MLParameterKey.Parameters dictionary. - Create a new update task with your custom model configuration.

See Personalizing a Model with On-Device Updates.

Scoping parameter keys

See: https://developer.apple.com/documentation/CoreML/MLParameterKey

func MLParameterKeyFromID

func MLParameterKeyFromID(id objc.ID) MLParameterKey

MLParameterKeyFromID constructs a MLParameterKey from an objc.ID.

The keys for the parameter dictionary in a model configuration or a model update context.

func NewMLParameterKey

func NewMLParameterKey() MLParameterKey

NewMLParameterKey creates a new MLParameterKey instance.

func (MLParameterKey) Autorelease

func (p MLParameterKey) Autorelease() MLParameterKey

Autorelease adds the receiver to the current autorelease pool.

func (MLParameterKey) AvailableComputeDevices

func (p MLParameterKey) AvailableComputeDevices() objectivec.IObject

The list of available compute devices that the model’s prediction methods use.

See: https://developer.apple.com/documentation/coreml/mlmodel/availablecomputedevices-6klyt

func (MLParameterKey) Configuration

func (p MLParameterKey) Configuration() IMLModelConfiguration

The configuration of the model set during initialization.

See: https://developer.apple.com/documentation/coreml/mlmodel/configuration

func (MLParameterKey) Init

func (p MLParameterKey) Init() MLParameterKey

Init initializes the instance.

func (MLParameterKey) ModelDescription

func (p MLParameterKey) ModelDescription() IMLModelDescription

Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.

See: https://developer.apple.com/documentation/coreml/mlmodel/modeldescription

func (MLParameterKey) Parameters

func (p MLParameterKey) Parameters() IMLParameterKey

A dictionary of configuration settings your app can override when loading a model.

See: https://developer.apple.com/documentation/coreml/mlmodelconfiguration/parameters

func (MLParameterKey) ScopedTo

func (p MLParameterKey) ScopedTo(scope string) IMLParameterKey

Creates a copy of a parameter key and adds the scope to it.

scope: A scope that targets the key to an internal component of a model.

Return Value

A new parameter key.

Discussion

Use this method to target:

- A specific layer of a model - A specific model within a pipeline model - A specific layer of a model within a pipeline model

For example, to target an MLParameterKey to a layer in a model, scope the key with the layer’s name.

To target a model within a pipeline model, scope the MLParameterKey with the model’s name.

To target a layer of a model within a pipeline model, start with an MLParameterKey you’ve already scoped to the model, and add an additional scope with the layer’s name.

By default, a pipeline model names its individual models in the pipeline as `model0`, `model1`, and so on.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/scoped(to:)

func (MLParameterKey) SetAvailableComputeDevices

func (p MLParameterKey) SetAvailableComputeDevices(value objectivec.IObject)

func (MLParameterKey) SetConfiguration

func (p MLParameterKey) SetConfiguration(value IMLModelConfiguration)

func (MLParameterKey) SetModelDescription

func (p MLParameterKey) SetModelDescription(value IMLModelDescription)

func (MLParameterKey) SetParameters

func (p MLParameterKey) SetParameters(value IMLParameterKey)

type MLParameterKeyClass

type MLParameterKeyClass struct {
	// contains filtered or unexported fields
}

func GetMLParameterKeyClass

func GetMLParameterKeyClass() MLParameterKeyClass

GetMLParameterKeyClass returns the class object for MLParameterKey.

func (MLParameterKeyClass) Alloc

Alloc allocates memory for a new instance of the class.

func (MLParameterKeyClass) Beta1

func (_MLParameterKeyClass MLParameterKeyClass) Beta1() MLParameterKey

The key you use to access the Adam optimizer’s first beta parameter.

Discussion

The value type for the [Beta1] key is a Double.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/beta1

func (MLParameterKeyClass) Beta2

func (_MLParameterKeyClass MLParameterKeyClass) Beta2() MLParameterKey

The key you use to access the Adam optimizer’s second beta parameter.

Discussion

The value type for the [Beta2] key is a Double.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/beta2

func (MLParameterKeyClass) Biases

func (_MLParameterKeyClass MLParameterKeyClass) Biases() MLParameterKey

The key you use to access the biases of a layer in a neural network model.

Discussion

The value type for the [Biases] key is an MLMultiArray. You must scope this key with the name of the specific neural network layer whose biases you’d like to access. See [ScopedTo].

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/biases

func (MLParameterKeyClass) Epochs

func (_MLParameterKeyClass MLParameterKeyClass) Epochs() MLParameterKey

The key you use to access the optimizer’s epochs parameter.

Discussion

The value type for the [Epochs] key is an Int64.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/epochs

func (MLParameterKeyClass) Eps

func (_MLParameterKeyClass MLParameterKeyClass) Eps() MLParameterKey

The key you use to access the Adam optimizer’s epsilon parameter.

Discussion

The value type for the [Eps] key is a Double.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/eps

func (MLParameterKeyClass) LearningRate

func (_MLParameterKeyClass MLParameterKeyClass) LearningRate() MLParameterKey

The key you use to access the optimizer’s learning rate parameter.

Discussion

The value type for the [LearningRate] key is a Double.

To modify a model’s learning rate midway through an MLUpdateTask, use its [ResumeWithParameters] method to set a new value for the model’s learning rate. You do this in the progress handler that you specified in the MLUpdateProgressHandlers instance when you created the update task using [UpdateTaskForModelAtURLTrainingDataConfigurationProgressHandlersError].

See Personalizing a Model with On-Device Updates.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/learningRate

func (MLParameterKeyClass) LinkedModelFileName

func (_MLParameterKeyClass MLParameterKeyClass) LinkedModelFileName() MLParameterKey

The key you use to access the linked model’s filename.

Discussion

The value type for the [LinkedModelFileName] key is a String.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/linkedModelFileName

func (MLParameterKeyClass) LinkedModelSearchPath

func (_MLParameterKeyClass MLParameterKeyClass) LinkedModelSearchPath() MLParameterKey

The key you use to access the linked model’s search path.

Discussion

The value type for the [LinkedModelSearchPath] key is a String.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/linkedModelSearchPath

func (MLParameterKeyClass) MiniBatchSize

func (_MLParameterKeyClass MLParameterKeyClass) MiniBatchSize() MLParameterKey

The key you use to access the optimizer’s mini batch-size parameter.

Discussion

The value type for the [MiniBatchSize] key is an Int64.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/miniBatchSize

func (MLParameterKeyClass) Momentum

func (_MLParameterKeyClass MLParameterKeyClass) Momentum() MLParameterKey

The key you use to access the stochastic gradient descent (SGD) optimizer’s momentum parameter.

Discussion

The value type for the [Momentum] key is a Double.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/momentum

func (MLParameterKeyClass) NumberOfNeighbors

func (_MLParameterKeyClass MLParameterKeyClass) NumberOfNeighbors() MLParameterKey

The key you use to access the number of neighbors that adjusts the affinity of a k-nearest-neighbor model.

Discussion

The value type for the [NumberOfNeighbors] key is an Int64.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/numberOfNeighbors

func (MLParameterKeyClass) Seed

func (_MLParameterKeyClass MLParameterKeyClass) Seed() MLParameterKey

The key you use to access the seed parameter that initializes the random number generator for the shuffle option.

Discussion

The value type for the [Seed] key is an Int64.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/seed

func (MLParameterKeyClass) Shuffle

func (_MLParameterKeyClass MLParameterKeyClass) Shuffle() MLParameterKey

The key you use to access the shuffle parameter, a Boolean value that determines whether the model randomizes the data between epochs.

Discussion

The value type for the [Shuffle] key is an Bool.

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/shuffle

func (MLParameterKeyClass) Weights

func (_MLParameterKeyClass MLParameterKeyClass) Weights() MLParameterKey

The key you use to access the weights of a layer in a neural network model.

Discussion

The value type for the [Weights] key is an MLMultiArray. You must scope this key with the name of the specific neural network layer whose weights you’d like to access. See [ScopedTo].

See: https://developer.apple.com/documentation/CoreML/MLParameterKey/weights

type MLPredictionOptions

type MLPredictionOptions struct {
	objectivec.Object
}

The options available when making a prediction.

Getting features

See: https://developer.apple.com/documentation/CoreML/MLPredictionOptions

func MLPredictionOptionsFromID

func MLPredictionOptionsFromID(id objc.ID) MLPredictionOptions

MLPredictionOptionsFromID constructs a MLPredictionOptions from an objc.ID.

The options available when making a prediction.

func NewMLPredictionOptions

func NewMLPredictionOptions() MLPredictionOptions

NewMLPredictionOptions creates a new MLPredictionOptions instance.

func (MLPredictionOptions) Autorelease

func (p MLPredictionOptions) Autorelease() MLPredictionOptions

Autorelease adds the receiver to the current autorelease pool.

func (MLPredictionOptions) Init

Init initializes the instance.

func (MLPredictionOptions) OutputBackings

func (p MLPredictionOptions) OutputBackings() foundation.INSDictionary

A dictionary of feature names and client-allocated buffers.

See: https://developer.apple.com/documentation/CoreML/MLPredictionOptions/outputBackings

func (MLPredictionOptions) SetOutputBackings

func (p MLPredictionOptions) SetOutputBackings(value foundation.INSDictionary)

type MLPredictionOptionsClass

type MLPredictionOptionsClass struct {
	// contains filtered or unexported fields
}

func GetMLPredictionOptionsClass

func GetMLPredictionOptionsClass() MLPredictionOptionsClass

GetMLPredictionOptionsClass returns the class object for MLPredictionOptions.

func (MLPredictionOptionsClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLReshapeFrequencyHint

type MLReshapeFrequencyHint int

See: https://developer.apple.com/documentation/CoreML/MLReshapeFrequencyHint

const (
	MLReshapeFrequencyHintFrequent   MLReshapeFrequencyHint = 0
	MLReshapeFrequencyHintInfrequent MLReshapeFrequencyHint = 1
)

func (MLReshapeFrequencyHint) String

func (e MLReshapeFrequencyHint) String() string

type MLSequence

type MLSequence struct {
	objectivec.Object
}

A machine learning collection type that stores a series of strings or integers.

Overview

A sequence stores a series of integers or strings of any length as the underlying type of an MLFeatureValue. Some classifier models — typically natural language models, such as an NLTagger — produce an MLSequence feature value from their output features.

Identifying the sequence’s element type

Retrieving the Sequence’s Values

See: https://developer.apple.com/documentation/CoreML/MLSequence

func MLSequenceFromID

func MLSequenceFromID(id objc.ID) MLSequence

MLSequenceFromID constructs a MLSequence from an objc.ID.

A machine learning collection type that stores a series of strings or integers.

func NewMLSequence

func NewMLSequence() MLSequence

NewMLSequence creates a new MLSequence instance.

func NewSequenceEmptySequenceWithType

func NewSequenceEmptySequenceWithType(type_ MLFeatureType) MLSequence

Creates an empty sequence of strings or integers.

type: An MLFeatureType instance that determines the sequence’s element type, which must be either [MLFeatureType.string] or [MLFeatureType.int64]. // [MLFeatureType.int64]: https://developer.apple.com/documentation/CoreML/MLFeatureType/int64 [MLFeatureType.string]: https://developer.apple.com/documentation/CoreML/MLFeatureType/string MLFeatureType: https://developer.apple.com/documentation/CoreML/MLFeatureType

See: https://developer.apple.com/documentation/CoreML/MLSequence/init(empty:)

func NewSequenceWithInt64Array

func NewSequenceWithInt64Array(int64Values []foundation.NSNumber) MLSequence

Creates a sequence of integers from an array of numbers.

int64Values: An array of integer values represented as [NSNumber] instances. // [NSNumber]: https://developer.apple.com/documentation/Foundation/NSNumber

See: https://developer.apple.com/documentation/CoreML/MLSequence/init(int64s:)

func NewSequenceWithStringArray

func NewSequenceWithStringArray(stringValues []string) MLSequence

Creates a sequence of strings from a string array.

stringValues: The array of strings for the sequence.

See: https://developer.apple.com/documentation/CoreML/MLSequence/init(strings:)

func (MLSequence) Autorelease

func (s MLSequence) Autorelease() MLSequence

Autorelease adds the receiver to the current autorelease pool.

func (MLSequence) EncodeWithCoder

func (s MLSequence) EncodeWithCoder(coder foundation.INSCoder)

func (MLSequence) Init

func (s MLSequence) Init() MLSequence

Init initializes the instance.

func (MLSequence) Int64Values

func (s MLSequence) Int64Values() []foundation.NSNumber

An array of 64-bit integers in the sequence.

Discussion

Only use this property when the sequence’s [Type] is MLFeatureType.int64.

See: https://developer.apple.com/documentation/CoreML/MLSequence/int64Values

func (MLSequence) StringValues

func (s MLSequence) StringValues() []string

An array of strings in the sequence.

Discussion

Only use this property when the sequence’s [Type] is MLFeatureType.string.

See: https://developer.apple.com/documentation/CoreML/MLSequence/stringValues

func (MLSequence) Type

func (s MLSequence) Type() MLFeatureType

The underlying type of the sequence’s elements.

Discussion

The sequence’s underlying element type can only be either MLFeatureType.string or MLFeatureType.int64. Use this value to determine whether to access [StringValues] or [Int64Values] at runtime.

See: https://developer.apple.com/documentation/CoreML/MLSequence/type

type MLSequenceClass

type MLSequenceClass struct {
	// contains filtered or unexported fields
}

func GetMLSequenceClass

func GetMLSequenceClass() MLSequenceClass

GetMLSequenceClass returns the class object for MLSequence.

func (MLSequenceClass) Alloc

func (mc MLSequenceClass) Alloc() MLSequence

Alloc allocates memory for a new instance of the class.

type MLSequenceConstraint

type MLSequenceConstraint struct {
	objectivec.Object
}

The constraints for a sequence feature.

Accessing the constraints

See: https://developer.apple.com/documentation/CoreML/MLSequenceConstraint

func MLSequenceConstraintFromID

func MLSequenceConstraintFromID(id objc.ID) MLSequenceConstraint

MLSequenceConstraintFromID constructs a MLSequenceConstraint from an objc.ID.

The constraints for a sequence feature.

func NewMLSequenceConstraint

func NewMLSequenceConstraint() MLSequenceConstraint

NewMLSequenceConstraint creates a new MLSequenceConstraint instance.

func (MLSequenceConstraint) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLSequenceConstraint) CountRange

func (s MLSequenceConstraint) CountRange() foundation.NSRange

The range of values allowed for the sequence’s length.

See: https://developer.apple.com/documentation/CoreML/MLSequenceConstraint/countRange

func (MLSequenceConstraint) DictionaryConstraint

func (s MLSequenceConstraint) DictionaryConstraint() IMLDictionaryConstraint

The constraint for a dictionary feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/dictionaryconstraint

func (MLSequenceConstraint) EncodeWithCoder

func (s MLSequenceConstraint) EncodeWithCoder(coder foundation.INSCoder)

func (MLSequenceConstraint) ImageConstraint

func (s MLSequenceConstraint) ImageConstraint() IMLImageConstraint

The size and format constraints for an image feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/imageconstraint

func (MLSequenceConstraint) Init

Init initializes the instance.

func (MLSequenceConstraint) MultiArrayConstraint

func (s MLSequenceConstraint) MultiArrayConstraint() IMLMultiArrayConstraint

The constraints on a multidimensional array feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/multiarrayconstraint

func (MLSequenceConstraint) SequenceConstraint

func (s MLSequenceConstraint) SequenceConstraint() IMLSequenceConstraint

The constraints for a sequence feature.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/sequenceconstraint

func (MLSequenceConstraint) SetDictionaryConstraint

func (s MLSequenceConstraint) SetDictionaryConstraint(value IMLDictionaryConstraint)

func (MLSequenceConstraint) SetImageConstraint

func (s MLSequenceConstraint) SetImageConstraint(value IMLImageConstraint)

func (MLSequenceConstraint) SetMultiArrayConstraint

func (s MLSequenceConstraint) SetMultiArrayConstraint(value IMLMultiArrayConstraint)

func (MLSequenceConstraint) SetSequenceConstraint

func (s MLSequenceConstraint) SetSequenceConstraint(value IMLSequenceConstraint)

func (MLSequenceConstraint) SetStateConstraint

func (s MLSequenceConstraint) SetStateConstraint(value IMLStateConstraint)

func (MLSequenceConstraint) StateConstraint

func (s MLSequenceConstraint) StateConstraint() IMLStateConstraint

The state feature value constraint.

See: https://developer.apple.com/documentation/coreml/mlfeaturedescription/stateconstraint

func (MLSequenceConstraint) ValueDescription

func (s MLSequenceConstraint) ValueDescription() IMLFeatureDescription

The description that all sequence elements must match.

See: https://developer.apple.com/documentation/CoreML/MLSequenceConstraint/valueDescription

type MLSequenceConstraintClass

type MLSequenceConstraintClass struct {
	// contains filtered or unexported fields
}

func GetMLSequenceConstraintClass

func GetMLSequenceConstraintClass() MLSequenceConstraintClass

GetMLSequenceConstraintClass returns the class object for MLSequenceConstraint.

func (MLSequenceConstraintClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLSpecializationStrategy

type MLSpecializationStrategy int

See: https://developer.apple.com/documentation/CoreML/MLSpecializationStrategy

const (
	MLSpecializationStrategyDefault        MLSpecializationStrategy = 0
	MLSpecializationStrategyFastPrediction MLSpecializationStrategy = 1
)

func (MLSpecializationStrategy) String

func (e MLSpecializationStrategy) String() string

type MLState

type MLState struct {
	objectivec.Object
}

Handle to the state buffers.

Overview

A stateful model maintains a state from one prediction to another by storing the information in the state buffers. To use such a model, the client must request the model to create state buffers and get MLState object, which is the handle to those buffers. Then, at the prediction time, pass the MLState object in one of the stateful prediction functions.

The object is a handle to the state buffers. The client shall not read or write the buffers while a prediction is in-flight.

Each stateful prediction that uses the same MLState must be serialized. Otherwise, if two such predictions run concurrently, the behavior is undefined.

See: https://developer.apple.com/documentation/CoreML/MLState

func MLStateFromID

func MLStateFromID(id objc.ID) MLState

MLStateFromID constructs a MLState from an objc.ID.

Handle to the state buffers.

func NewMLState

func NewMLState() MLState

NewMLState creates a new MLState instance.

func (MLState) Autorelease

func (s MLState) Autorelease() MLState

Autorelease adds the receiver to the current autorelease pool.

func (MLState) Init

func (s MLState) Init() MLState

Init initializes the instance.

type MLStateClass

type MLStateClass struct {
	// contains filtered or unexported fields
}

func GetMLStateClass

func GetMLStateClass() MLStateClass

GetMLStateClass returns the class object for MLState.

func (MLStateClass) Alloc

func (mc MLStateClass) Alloc() MLState

Alloc allocates memory for a new instance of the class.

type MLStateConstraint

type MLStateConstraint struct {
	objectivec.Object
}

Constraint of a state feature value.

Inspecting a state constraint

See: https://developer.apple.com/documentation/CoreML/MLStateConstraint

func MLStateConstraintFromID

func MLStateConstraintFromID(id objc.ID) MLStateConstraint

MLStateConstraintFromID constructs a MLStateConstraint from an objc.ID.

Constraint of a state feature value.

func NewMLStateConstraint

func NewMLStateConstraint() MLStateConstraint

NewMLStateConstraint creates a new MLStateConstraint instance.

func (MLStateConstraint) Autorelease

func (s MLStateConstraint) Autorelease() MLStateConstraint

Autorelease adds the receiver to the current autorelease pool.

func (MLStateConstraint) BufferShape

func (s MLStateConstraint) BufferShape() int

The shape of the state buffer.

See: https://developer.apple.com/documentation/coreml/mlstateconstraint/buffershape-4zb3w

func (MLStateConstraint) DataType

The data type of scalars in the state buffer.

See: https://developer.apple.com/documentation/CoreML/MLStateConstraint/dataType

func (MLStateConstraint) EncodeWithCoder

func (s MLStateConstraint) EncodeWithCoder(coder foundation.INSCoder)

func (MLStateConstraint) Init

Init initializes the instance.

func (MLStateConstraint) SetBufferShape

func (s MLStateConstraint) SetBufferShape(value int)

type MLStateConstraintClass

type MLStateConstraintClass struct {
	// contains filtered or unexported fields
}

func GetMLStateConstraintClass

func GetMLStateConstraintClass() MLStateConstraintClass

GetMLStateConstraintClass returns the class object for MLStateConstraint.

func (MLStateConstraintClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLTask

type MLTask struct {
	objectivec.Object
}

An abstract base class for machine learning tasks.

Overview

You don’t create use this class directly. Instead, use a class that inherits from this one, such as MLUpdateTask.

Identifying a task

Starting and stopping a task

Checking the state of a task

  • MLTask.State: The current state of the machine learning task.
  • MLTask.Error: The underlying error if the task is in a failed state.

See: https://developer.apple.com/documentation/CoreML/MLTask

func MLTaskFromID

func MLTaskFromID(id objc.ID) MLTask

MLTaskFromID constructs a MLTask from an objc.ID.

An abstract base class for machine learning tasks.

func NewMLTask

func NewMLTask() MLTask

NewMLTask creates a new MLTask instance.

func (MLTask) Autorelease

func (t MLTask) Autorelease() MLTask

Autorelease adds the receiver to the current autorelease pool.

func (MLTask) Cancel

func (t MLTask) Cancel()

Cancels a machine learning task before it completes.

See: https://developer.apple.com/documentation/CoreML/MLTask/cancel()

func (MLTask) Error

func (t MLTask) Error() foundation.INSError

The underlying error if the task is in a failed state.

See: https://developer.apple.com/documentation/CoreML/MLTask/error

func (MLTask) Init

func (t MLTask) Init() MLTask

Init initializes the instance.

func (MLTask) Resume

func (t MLTask) Resume()

Begins or resumes a machine learning task.

Discussion

Use this method to start a task for the first time or resumes a task that has paused. Tasks pause when they notify your app’s progress handlers, such as those you provide to an MLUpdateProgressHandlers instance.

See: https://developer.apple.com/documentation/CoreML/MLTask/resume()

func (MLTask) State

func (t MLTask) State() MLTaskState

The current state of the machine learning task.

See: https://developer.apple.com/documentation/CoreML/MLTask/state

func (MLTask) TaskIdentifier

func (t MLTask) TaskIdentifier() string

A unique name of the task to distinguish it from all other tasks at runtime.

See: https://developer.apple.com/documentation/CoreML/MLTask/taskIdentifier

type MLTaskClass

type MLTaskClass struct {
	// contains filtered or unexported fields
}

func GetMLTaskClass

func GetMLTaskClass() MLTaskClass

GetMLTaskClass returns the class object for MLTask.

func (MLTaskClass) Alloc

func (mc MLTaskClass) Alloc() MLTask

Alloc allocates memory for a new instance of the class.

type MLTaskState

type MLTaskState int

See: https://developer.apple.com/documentation/CoreML/MLTaskState

const (
	// MLTaskStateCancelling: The state of a machine learning task that’s in mid-termination, before it could finish successfully.
	MLTaskStateCancelling MLTaskState = 3
	// MLTaskStateCompleted: The state of a machine learning task that has finished successfully.
	MLTaskStateCompleted MLTaskState = 4
	// MLTaskStateFailed: The state of a machine learning task that has terminated due to an error.
	MLTaskStateFailed MLTaskState = 5
	// MLTaskStateRunning: The state of a machine learning task that’s executing.
	MLTaskStateRunning MLTaskState = 2
	// MLTaskStateSuspended: The state of a machine learning task that’s paused.
	MLTaskStateSuspended MLTaskState = 1
)

func (MLTaskState) String

func (e MLTaskState) String() string

type MLUpdateContext

type MLUpdateContext struct {
	objectivec.Object
}

The context an update task provides to your app’s completion and update progress handlers.

Getting the update context

Evaluating the update

Saving an updated model

See: https://developer.apple.com/documentation/CoreML/MLUpdateContext

func MLUpdateContextFromID

func MLUpdateContextFromID(id objc.ID) MLUpdateContext

MLUpdateContextFromID constructs a MLUpdateContext from an objc.ID.

The context an update task provides to your app’s completion and update progress handlers.

func NewMLUpdateContext

func NewMLUpdateContext() MLUpdateContext

NewMLUpdateContext creates a new MLUpdateContext instance.

func (MLUpdateContext) Autorelease

func (u MLUpdateContext) Autorelease() MLUpdateContext

Autorelease adds the receiver to the current autorelease pool.

func (MLUpdateContext) Event

The event type that triggered an update task to notify your app’s completion and update progress handlers.

See: https://developer.apple.com/documentation/CoreML/MLUpdateContext/event

func (MLUpdateContext) Init

Init initializes the instance.

func (MLUpdateContext) Metrics

The training metrics of the model for the update task, contained in a dictionary.

Discussion

Use the MLMetricKey to access the values within the dictionary.

See: https://developer.apple.com/documentation/CoreML/MLUpdateContext/metrics

func (MLUpdateContext) Model

func (u MLUpdateContext) Model() IMLModel

The underlying Core ML model stored in memory.

See: https://developer.apple.com/documentation/CoreML/MLUpdateContext/model

func (MLUpdateContext) Parameters

func (u MLUpdateContext) Parameters() foundation.INSDictionary

The parameters for the update task.

See: https://developer.apple.com/documentation/CoreML/MLUpdateContext/parameters

func (MLUpdateContext) Task

func (u MLUpdateContext) Task() IMLUpdateTask

The update task that generated the update context.

See: https://developer.apple.com/documentation/CoreML/MLUpdateContext/task

type MLUpdateContextClass

type MLUpdateContextClass struct {
	// contains filtered or unexported fields
}

func GetMLUpdateContextClass

func GetMLUpdateContextClass() MLUpdateContextClass

GetMLUpdateContextClass returns the class object for MLUpdateContext.

func (MLUpdateContextClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLUpdateContextHandler

type MLUpdateContextHandler = func(*MLUpdateContext)

MLUpdateContextHandler handles The closure an update task uses to notify your app.

Used by:

type MLUpdateProgressEvent

type MLUpdateProgressEvent int

See: https://developer.apple.com/documentation/CoreML/MLUpdateProgressEvent

const (
	// MLUpdateProgressEventEpochEnd: An event that represents the end of training epoch.
	MLUpdateProgressEventEpochEnd MLUpdateProgressEvent = 2
	// MLUpdateProgressEventMiniBatchEnd: An event that represents the end of a mini-batch within a training epoch.
	MLUpdateProgressEventMiniBatchEnd MLUpdateProgressEvent = 4
	// MLUpdateProgressEventTrainingBegin: An event that represents the start of training.
	MLUpdateProgressEventTrainingBegin MLUpdateProgressEvent = 1
)

func (MLUpdateProgressEvent) String

func (e MLUpdateProgressEvent) String() string

type MLUpdateProgressHandlers

type MLUpdateProgressHandlers struct {
	objectivec.Object
}

A collection of closures an update task uses to notify your app of its progress.

Creating progress handlers

See: https://developer.apple.com/documentation/CoreML/MLUpdateProgressHandlers

func MLUpdateProgressHandlersFromID

func MLUpdateProgressHandlersFromID(id objc.ID) MLUpdateProgressHandlers

MLUpdateProgressHandlersFromID constructs a MLUpdateProgressHandlers from an objc.ID.

A collection of closures an update task uses to notify your app of its progress.

func NewMLUpdateProgressHandlers

func NewMLUpdateProgressHandlers() MLUpdateProgressHandlers

NewMLUpdateProgressHandlers creates a new MLUpdateProgressHandlers instance.

func (MLUpdateProgressHandlers) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (MLUpdateProgressHandlers) Init

Init initializes the instance.

func (MLUpdateProgressHandlers) InitForEventsProgressHandler

func (u MLUpdateProgressHandlers) InitForEventsProgressHandler(ctx context.Context, interestedEvents MLUpdateProgressEvent, progressHandler MLUpdateContextHandler) (*MLUpdateContext, error)

InitForEventsProgressHandler is a synchronous wrapper around MLUpdateProgressHandlers.InitForEventsProgressHandlerCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (MLUpdateProgressHandlers) InitForEventsProgressHandlerCompletionHandler

func (u MLUpdateProgressHandlers) InitForEventsProgressHandlerCompletionHandler(interestedEvents MLUpdateProgressEvent, progressHandler MLUpdateContextHandler, completionHandler MLUpdateContextHandler) MLUpdateProgressHandlers

Creates the collection of closures an update task uses to notify your app of its progress.

interestedEvents: The events for which the update task will call your closures for, contained in an option set.

progressHandler: The closure an update task uses to notify your app. The update task only uses this closure for the events you specified in `interestedEvents`.

completionHandler: The closure that an update tasks uses to notify you when it is complete.

See: https://developer.apple.com/documentation/CoreML/MLUpdateProgressHandlers/init(forEvents:progressHandler:completionHandler:)

type MLUpdateProgressHandlersClass

type MLUpdateProgressHandlersClass struct {
	// contains filtered or unexported fields
}

func GetMLUpdateProgressHandlersClass

func GetMLUpdateProgressHandlersClass() MLUpdateProgressHandlersClass

GetMLUpdateProgressHandlersClass returns the class object for MLUpdateProgressHandlers.

func (MLUpdateProgressHandlersClass) Alloc

Alloc allocates memory for a new instance of the class.

type MLUpdateTask

type MLUpdateTask struct {
	MLTask
}

A task that updates a model with additional training data.

Overview

Use an MLUpdateTask to update a machine learning model on a user’s device.

Starting and Resuming an Update

See: https://developer.apple.com/documentation/CoreML/MLUpdateTask

func MLUpdateTaskFromID

func MLUpdateTaskFromID(id objc.ID) MLUpdateTask

MLUpdateTaskFromID constructs a MLUpdateTask from an objc.ID.

A task that updates a model with additional training data.

func NewMLUpdateTask

func NewMLUpdateTask() MLUpdateTask

NewMLUpdateTask creates a new MLUpdateTask instance.

func NewUpdateTaskForModelAtURLTrainingDataConfigurationProgressHandlersError

func NewUpdateTaskForModelAtURLTrainingDataConfigurationProgressHandlersError(modelURL foundation.INSURL, trainingData MLBatchProvider, configuration IMLModelConfiguration, progressHandlers IMLUpdateProgressHandlers) (MLUpdateTask, error)

Creates a task that updates the model at the URL with the training data and configuration, and calls the progress handlers during and after the update.

modelURL: The location in the file system of a model file (`XCUIElementTypeMlmodelc`).

trainingData: The update data for the model, contained in a batch provider.

configuration: The model settings for an updated model object.

progressHandlers: The closures the task calls during the update process.

See: https://developer.apple.com/documentation/CoreML/MLUpdateTask/init(forModelAt:trainingData:configuration:progressHandlers:)

func NewUpdateTaskForModelAtURLTrainingDataProgressHandlersError

func NewUpdateTaskForModelAtURLTrainingDataProgressHandlersError(modelURL foundation.INSURL, trainingData MLBatchProvider, progressHandlers IMLUpdateProgressHandlers) (MLUpdateTask, error)

Creates a task that updates the model at the URL with the training data, and calls the progress handlers during and after the update.

modelURL: The location in the file system of a model file (`XCUIElementTypeMlmodelc`).

trainingData: The update data for the model, contained in a batch provider.

progressHandlers: The closures the task calls during the update process.

See: https://developer.apple.com/documentation/CoreML/MLUpdateTask/init(forModelAt:trainingData:progressHandlers:)

func (MLUpdateTask) Autorelease

func (u MLUpdateTask) Autorelease() MLUpdateTask

Autorelease adds the receiver to the current autorelease pool.

func (MLUpdateTask) Init

func (u MLUpdateTask) Init() MLUpdateTask

Init initializes the instance.

func (MLUpdateTask) ResumeWithParameters

func (u MLUpdateTask) ResumeWithParameters(updateParameters foundation.INSDictionary)

Resumes a model update with updated parameter values.

updateParameters: Model training parameter values to replace those currently set in the update task.

Discussion

Use this method to resume the model update task with newer parameter values. You use this method within the closures you provide in an MLUpdateProgressHandlers instance to resume the MLUpdateTask.

See: https://developer.apple.com/documentation/CoreML/MLUpdateTask/resume(withParameters:)

type MLUpdateTaskClass

type MLUpdateTaskClass struct {
	// contains filtered or unexported fields
}

func GetMLUpdateTaskClass

func GetMLUpdateTaskClass() MLUpdateTaskClass

GetMLUpdateTaskClass returns the class object for MLUpdateTask.

func (MLUpdateTaskClass) Alloc

func (mc MLUpdateTaskClass) Alloc() MLUpdateTask

Alloc allocates memory for a new instance of the class.

func (MLUpdateTaskClass) UpdateTaskForModelAtURLTrainingDataCompletionHandlerError

func (_MLUpdateTaskClass MLUpdateTaskClass) UpdateTaskForModelAtURLTrainingDataCompletionHandlerError(modelURL foundation.INSURL, trainingData MLBatchProvider, completionHandler func(*MLUpdateContext)) (MLUpdateTask, error)

Creates a task that updates the model at the URL with the training data, and calls the completion handler when the update completes.

modelURL: The location in the file system of a model file (`XCUIElementTypeMlmodelc`).

trainingData: The update data for the model, contained in a batch provider.

completionHandler: The closure the task calls when it finishes.

See: https://developer.apple.com/documentation/CoreML/MLUpdateTask/init(forModelAt:trainingData:completionHandler:)

func (MLUpdateTaskClass) UpdateTaskForModelAtURLTrainingDataConfigurationCompletionHandlerError

func (_MLUpdateTaskClass MLUpdateTaskClass) UpdateTaskForModelAtURLTrainingDataConfigurationCompletionHandlerError(modelURL foundation.INSURL, trainingData MLBatchProvider, configuration IMLModelConfiguration, completionHandler func(*MLUpdateContext)) (MLUpdateTask, error)

Creates a task that updates the model at the URL with the training data and configuration, and calls the completion handler when the update completes.

modelURL: The location in the file system of a model file (`XCUIElementTypeMlmodelc`).

trainingData: The update data for the model, contained in a batch provider.

configuration: The model settings for an updated model object.

completionHandler: The closure the task calls when it finishes.

See: https://developer.apple.com/documentation/CoreML/MLUpdateTask/init(forModelAt:trainingData:configuration:completionHandler:)

type MLWritable

type MLWritable interface {
	objectivec.IObject

	// Exports a machine learning file to the file system.
	//
	// See: https://developer.apple.com/documentation/CoreML/MLWritable/write(to:)
	WriteToURLError(url foundation.INSURL) (bool, error)
}

A set of methods that saves a machine learning type to the file system.

See: https://developer.apple.com/documentation/CoreML/MLWritable

type MLWritableObject

type MLWritableObject struct {
	objectivec.Object
}

MLWritableObject wraps an existing Objective-C object that conforms to the MLWritable protocol.

func MLWritableObjectFromID

func MLWritableObjectFromID(id objc.ID) MLWritableObject

MLWritableObjectFromID constructs a MLWritableObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (MLWritableObject) BaseObject

func (o MLWritableObject) BaseObject() objectivec.Object

func (MLWritableObject) WriteToURLError

func (o MLWritableObject) WriteToURLError(url foundation.INSURL) (bool, error)

Exports a machine learning file to the file system.

url: The location in the file system where the file should be written.

See: https://developer.apple.com/documentation/CoreML/MLWritable/write(to:)

type VoidHandler

type VoidHandler = func()

VoidHandler handles In Swift, a closure the multiarray calls in its deinitializer.

Used by:

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL