coremlruntime

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package coremlruntime wraps private CoreML runtime entry points that are useful when working with compiled models, stateful prediction, and client-supplied output backings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFeatureProvider

func NewFeatureProvider(values map[string]coreml.MLFeatureValue) (coreml.MLDictionaryFeatureProvider, error)

NewFeatureProvider builds an MLDictionaryFeatureProvider from prebuilt feature values.

func OutputBackingsDictionary

func OutputBackingsDictionary(backings map[string]objectivec.IObject) foundation.NSDictionary

OutputBackingsDictionary builds an NSDictionary suitable for MLPredictionOptions output backings.

Types

type InputPortBinder

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

InputPortBinder wraps CoreML's private input-port binder.

func NewInputPortBinder

func NewInputPortBinder(port, featureDescription objectivec.IObject) InputPortBinder

NewInputPortBinder constructs an input-port binder for a port/feature pair.

func (InputPortBinder) BindMemoryObject

func (b InputPortBinder) BindMemoryObject(value coreml.MLFeatureValue) error

BindMemoryObject binds a feature value directly when the runtime supports it.

func (InputPortBinder) CopyFeatureValue

func (b InputPortBinder) CopyFeatureValue(value coreml.MLFeatureValue) error

CopyFeatureValue copies a feature value into the bound port.

func (InputPortBinder) Raw

Raw returns the underlying private input-port binder object.

func (InputPortBinder) Reset

func (b InputPortBinder) Reset()

Reset resets binder state between submissions.

func (InputPortBinder) ReusableForFeatureValue

func (b InputPortBinder) ReusableForFeatureValue(value coreml.MLFeatureValue) (reusable bool, direct bool)

ReusableForFeatureValue reports whether the binder can be reused for the value and whether the runtime intends to bind it directly.

func (InputPortBinder) SetPixelBufferPool

func (b InputPortBinder) SetPixelBufferPool(pool PixelBufferPool)

SetPixelBufferPool routes image binding through the given pixel-buffer pool.

type Model

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

Model wraps a loaded CoreML model with private runtime helpers.

func Load

func Load(path string, cfg *coremlconfig.Config) (*Model, error)

Load opens a compiled .mlmodelc bundle.

func Wrap

func Wrap(raw coreml.MLModel) *Model

Wrap exposes an existing CoreML model through the runtime helper surface.

func (*Model) NewState

func (m *Model) NewState() coreml.MLState

NewState allocates a new CoreML state handle for a stateful model.

func (*Model) NewStateWithClientBuffers

func (m *Model) NewStateWithClientBuffers(buffers objectivec.IObject) coreml.MLState

NewStateWithClientBuffers allocates a new CoreML state handle backed by client-supplied buffers.

func (*Model) PredictFeatureValues

func (m *Model) PredictFeatureValues(values map[string]coreml.MLFeatureValue) (*Prediction, error)

PredictFeatureValues runs inference using a map of prebuilt feature values.

func (*Model) PredictProvider

func (m *Model) PredictProvider(provider coreml.MLFeatureProvider) (*Prediction, error)

PredictProvider runs inference using a caller-supplied feature provider.

func (*Model) PredictProviderWithState

func (m *Model) PredictProviderWithState(provider coreml.MLFeatureProvider, state coreml.IMLState) (*Prediction, error)

PredictProviderWithState runs inference using a caller-supplied state handle.

func (*Model) PredictProviderWithStateOptions

func (m *Model) PredictProviderWithStateOptions(provider coreml.MLFeatureProvider, state coreml.IMLState, options coreml.IMLPredictionOptions) (*Prediction, error)

PredictProviderWithStateOptions runs inference with optional state and prediction options.

func (*Model) PrepareWithConcurrencyHint

func (m *Model) PrepareWithConcurrencyHint(hint int64)

PrepareWithConcurrencyHint forwards the private preparation hint to the model.

func (*Model) Raw

func (m *Model) Raw() coreml.MLModel

Raw returns the underlying MLModel.

func (*Model) SupportsConcurrentSubmissions

func (m *Model) SupportsConcurrentSubmissions() bool

SupportsConcurrentSubmissions reports whether the model runtime advertises concurrent submission support.

type OutputBackingsVerifier

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

OutputBackingsVerifier wraps CoreML's private output-backing verifier.

func NewOutputBackingsVerifier

func NewOutputBackingsVerifier(descriptions objectivec.IObject) OutputBackingsVerifier

NewOutputBackingsVerifier constructs a verifier for a model's output descriptions.

func (OutputBackingsVerifier) VerifyOutputBacking

func (v OutputBackingsVerifier) VerifyOutputBacking(backing, feature objectivec.IObject) error

VerifyOutputBacking verifies a single output backing object.

func (OutputBackingsVerifier) VerifyOutputBackings

func (v OutputBackingsVerifier) VerifyOutputBackings(backings foundation.INSDictionary, predictionUsesBatch bool) error

VerifyOutputBackings verifies a dictionary of output backings against the descriptions.

func (OutputBackingsVerifier) VerifyPixelBufferOutputBacking

func (v OutputBackingsVerifier) VerifyPixelBufferOutputBacking(backing corevideo.CVImageBufferRef, feature objectivec.IObject) error

VerifyPixelBufferOutputBacking verifies a pixel-buffer output backing.

type OutputPortBinder

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

OutputPortBinder wraps CoreML's private output-port binder.

func NewOutputPortBinder

func NewOutputPortBinder(port, featureDescription objectivec.IObject) OutputPortBinder

NewOutputPortBinder constructs an output-port binder for a port/feature pair.

func (OutputPortBinder) Bind

func (b OutputPortBinder) Bind() error

Bind binds the currently configured output backing.

func (OutputPortBinder) DirectlyBindOutputBacking

func (b OutputPortBinder) DirectlyBindOutputBacking(backing objectivec.IObject) error

DirectlyBindOutputBacking asks the runtime to directly bind the output backing.

func (OutputPortBinder) MakeFeatureValue

func (b OutputPortBinder) MakeFeatureValue() (coreml.MLFeatureValue, error)

MakeFeatureValue materializes a feature value from the current output binding.

func (OutputPortBinder) MakeFeatureValueFromOutputBacking

func (b OutputPortBinder) MakeFeatureValueFromOutputBacking(backing objectivec.IObject) (coreml.MLFeatureValue, error)

MakeFeatureValueFromOutputBacking materializes a feature value from a backing object.

func (OutputPortBinder) Raw

Raw returns the underlying private output-port binder object.

func (OutputPortBinder) Reset

func (b OutputPortBinder) Reset()

Reset resets binder state between submissions.

func (OutputPortBinder) ReusableForOutputBacking

func (b OutputPortBinder) ReusableForOutputBacking(backing objectivec.IObject) (reusable bool, direct bool)

ReusableForOutputBacking reports whether the binder can be reused for the backing and whether the runtime intends to bind it directly.

func (OutputPortBinder) SetOutputBacking

func (b OutputPortBinder) SetOutputBacking(backing objectivec.IObject)

SetOutputBacking sets the output backing object on the binder.

func (OutputPortBinder) SetPixelBufferPool

func (b OutputPortBinder) SetPixelBufferPool(pool PixelBufferPool)

SetPixelBufferPool routes image output binding through the given pool.

type PixelBufferPool

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

PixelBufferPool wraps CoreML's private pixel-buffer pool helper.

func NewPixelBufferPool

func NewPixelBufferPool() PixelBufferPool

NewPixelBufferPool creates a private CoreML pixel-buffer pool wrapper.

func (PixelBufferPool) Cache

Cache returns the pool's internal cache dictionary.

func (PixelBufferPool) CreatePixelBuffer

func (p PixelBufferPool) CreatePixelBuffer(size corefoundation.CGSize, pixelFormat uint32) (corevideo.CVImageBufferRef, error)

CreatePixelBuffer allocates a pixel buffer from the pool.

func (PixelBufferPool) Raw

Raw returns the underlying private pixel-buffer pool object.

type Prediction

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

Prediction retains a CoreML prediction result so callers can inspect outputs without immediately materializing them.

func (*Prediction) Close

func (p *Prediction) Close() error

Close releases the retained prediction result.

func (*Prediction) FeatureNames

func (p *Prediction) FeatureNames() []string

FeatureNames returns the prediction's feature names.

func (*Prediction) FeatureValue

func (p *Prediction) FeatureValue(name string) coreml.MLFeatureValue

FeatureValue returns a named output feature value.

func (*Prediction) MultiArrays

func (p *Prediction) MultiArrays() (map[string]coreml.MLMultiArray, error)

MultiArrays returns the prediction's multi-array outputs.

func (*Prediction) Provider

Provider returns the retained prediction provider.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL