coremlruntime

package
v0.6.20 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

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(_ map[string]any) (any, error)

NewFeatureProvider builds an MLDictionaryFeatureProvider from prebuilt feature values.

func OutputBackingsDictionary

func OutputBackingsDictionary(_ map[string]any) (any, error)

OutputBackingsDictionary builds an NSDictionary suitable for MLPredictionOptions output backings.

Types

type InputPortBinder

type InputPortBinder struct{}

InputPortBinder wraps CoreML's private input-port binder.

func NewInputPortBinder

func NewInputPortBinder(_ uintptr, _ any) InputPortBinder

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

func (InputPortBinder) BindMemoryObject

func (b InputPortBinder) BindMemoryObject(_ any) error

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

func (InputPortBinder) CopyFeatureValue

func (b InputPortBinder) CopyFeatureValue(_ any) error

CopyFeatureValue copies a feature value into the bound port.

func (InputPortBinder) Raw

func (b InputPortBinder) Raw() any

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(_ any) (bool, bool)

ReusableForFeatureValue reports whether the binder can be reused for the value.

func (InputPortBinder) SetPixelBufferPool

func (b InputPortBinder) SetPixelBufferPool(_ PixelBufferPool)

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

type Model

type Model struct{}

Model wraps a loaded CoreML model with private runtime helpers.

func Load

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

Load opens a compiled .mlmodelc bundle. Only supported on darwin.

func Wrap

func Wrap(_ any) *Model

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

func (*Model) Close

func (m *Model) Close() error

Close releases the underlying MLModel if owned.

func (*Model) NewState

func (m *Model) NewState() any

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

func (*Model) NewStateWithClientBuffers

func (m *Model) NewStateWithClientBuffers(_ any) any

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

func (*Model) PredictFeatureValues

func (m *Model) PredictFeatureValues(_ map[string]any) (*Prediction, error)

PredictFeatureValues runs inference using a map of prebuilt feature values.

func (*Model) PredictProvider

func (m *Model) PredictProvider(_ any) (*Prediction, error)

PredictProvider runs inference using a caller-supplied feature provider.

func (*Model) PredictProviderWithState

func (m *Model) PredictProviderWithState(_, _ any) (*Prediction, error)

PredictProviderWithState runs inference using a caller-supplied state handle.

func (*Model) PredictProviderWithStateOptions

func (m *Model) PredictProviderWithStateOptions(_, _, _ any) (*Prediction, error)

PredictProviderWithStateOptions runs inference with optional state and prediction options.

func (*Model) PrepareWithConcurrencyHint

func (m *Model) PrepareWithConcurrencyHint(_ int64)

PrepareWithConcurrencyHint forwards the private preparation hint to the model.

func (*Model) Raw

func (m *Model) Raw() any

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{}

OutputBackingsVerifier wraps CoreML's private output-backing verifier.

func NewOutputBackingsVerifier

func NewOutputBackingsVerifier(_ any) OutputBackingsVerifier

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

func (OutputBackingsVerifier) VerifyOutputBacking

func (v OutputBackingsVerifier) VerifyOutputBacking(_, _ any) error

VerifyOutputBacking verifies a single output backing object.

func (OutputBackingsVerifier) VerifyOutputBackings

func (v OutputBackingsVerifier) VerifyOutputBackings(_ any, _ bool) error

VerifyOutputBackings verifies a dictionary of output backings against the descriptions.

func (OutputBackingsVerifier) VerifyPixelBufferOutputBacking

func (v OutputBackingsVerifier) VerifyPixelBufferOutputBacking(_ uintptr, _ any) error

VerifyPixelBufferOutputBacking verifies a pixel-buffer output backing.

type OutputPortBinder

type OutputPortBinder struct{}

OutputPortBinder wraps CoreML's private output-port binder.

func NewOutputPortBinder

func NewOutputPortBinder(_ uintptr, _ any) 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(_ any) error

DirectlyBindOutputBacking asks the runtime to directly bind the output backing.

func (OutputPortBinder) MakeFeatureValue

func (b OutputPortBinder) MakeFeatureValue() (any, error)

MakeFeatureValue materializes a feature value from the current output binding.

func (OutputPortBinder) MakeFeatureValueFromOutputBacking

func (b OutputPortBinder) MakeFeatureValueFromOutputBacking(_ any) (any, error)

MakeFeatureValueFromOutputBacking materializes a feature value from a backing object.

func (OutputPortBinder) Raw

func (b OutputPortBinder) Raw() any

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(_ any) (bool, bool)

ReusableForOutputBacking reports whether the binder can be reused for the backing.

func (OutputPortBinder) SetOutputBacking

func (b OutputPortBinder) SetOutputBacking(_ any)

SetOutputBacking sets the output backing object on the binder.

func (OutputPortBinder) SetPixelBufferPool

func (b OutputPortBinder) SetPixelBufferPool(_ PixelBufferPool)

SetPixelBufferPool routes image output binding through the given pool.

type PixelBufferPool

type PixelBufferPool struct{}

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

func (p PixelBufferPool) Cache() any

Cache returns the pool's internal cache dictionary.

func (PixelBufferPool) CreatePixelBuffer

func (p PixelBufferPool) CreatePixelBuffer(_ any, _ uint32) (uintptr, error)

CreatePixelBuffer allocates a pixel buffer from the pool.

func (PixelBufferPool) Raw

func (p PixelBufferPool) Raw() any

Raw returns the underlying private pixel-buffer pool object.

type Prediction

type Prediction struct{}

Prediction retains a CoreML prediction result.

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(_ string) any

FeatureValue returns a named output feature value.

func (*Prediction) MultiArrays

func (p *Prediction) MultiArrays() (map[string]any, error)

MultiArrays returns the prediction's multi-array outputs.

func (*Prediction) Provider

func (p *Prediction) Provider() any

Provider returns the retained prediction provider.

Jump to

Keyboard shortcuts

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