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 ¶
- func NewFeatureProvider(_ map[string]any) (any, error)
- func OutputBackingsDictionary(_ map[string]any) (any, error)
- type InputPortBinder
- func (b InputPortBinder) BindMemoryObject(_ any) error
- func (b InputPortBinder) CopyFeatureValue(_ any) error
- func (b InputPortBinder) Raw() any
- func (b InputPortBinder) Reset()
- func (b InputPortBinder) ReusableForFeatureValue(_ any) (bool, bool)
- func (b InputPortBinder) SetPixelBufferPool(_ PixelBufferPool)
- type Model
- func (m *Model) Close() error
- func (m *Model) NewState() any
- func (m *Model) NewStateWithClientBuffers(_ any) any
- func (m *Model) PredictFeatureValues(_ map[string]any) (*Prediction, error)
- func (m *Model) PredictProvider(_ any) (*Prediction, error)
- func (m *Model) PredictProviderWithState(_, _ any) (*Prediction, error)
- func (m *Model) PredictProviderWithStateOptions(_, _, _ any) (*Prediction, error)
- func (m *Model) PrepareWithConcurrencyHint(_ int64)
- func (m *Model) Raw() any
- func (m *Model) SupportsConcurrentSubmissions() bool
- type OutputBackingsVerifier
- type OutputPortBinder
- func (b OutputPortBinder) Bind() error
- func (b OutputPortBinder) DirectlyBindOutputBacking(_ any) error
- func (b OutputPortBinder) MakeFeatureValue() (any, error)
- func (b OutputPortBinder) MakeFeatureValueFromOutputBacking(_ any) (any, error)
- func (b OutputPortBinder) Raw() any
- func (b OutputPortBinder) Reset()
- func (b OutputPortBinder) ReusableForOutputBacking(_ any) (bool, bool)
- func (b OutputPortBinder) SetOutputBacking(_ any)
- func (b OutputPortBinder) SetPixelBufferPool(_ PixelBufferPool)
- type PixelBufferPool
- type Prediction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFeatureProvider ¶
NewFeatureProvider builds an MLDictionaryFeatureProvider from prebuilt feature values.
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 (*Model) NewStateWithClientBuffers ¶
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 ¶
PrepareWithConcurrencyHint forwards the private preparation hint to the model.
func (*Model) SupportsConcurrentSubmissions ¶
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.