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(values map[string]coreml.MLFeatureValue) (coreml.MLDictionaryFeatureProvider, error)
- func OutputBackingsDictionary(backings map[string]objectivec.IObject) foundation.NSDictionary
- type InputPortBinder
- func (b InputPortBinder) BindMemoryObject(value coreml.MLFeatureValue) error
- func (b InputPortBinder) CopyFeatureValue(value coreml.MLFeatureValue) error
- func (b InputPortBinder) Raw() privatecoreml.MLE5InputPortBinder
- func (b InputPortBinder) Reset()
- func (b InputPortBinder) ReusableForFeatureValue(value coreml.MLFeatureValue) (reusable bool, direct bool)
- func (b InputPortBinder) SetPixelBufferPool(pool PixelBufferPool)
- type Model
- func (m *Model) NewState() coreml.MLState
- func (m *Model) NewStateWithClientBuffers(buffers objectivec.IObject) coreml.MLState
- func (m *Model) PredictFeatureValues(values map[string]coreml.MLFeatureValue) (*Prediction, error)
- func (m *Model) PredictProvider(provider coreml.MLFeatureProvider) (*Prediction, error)
- func (m *Model) PredictProviderWithState(provider coreml.MLFeatureProvider, state coreml.IMLState) (*Prediction, error)
- func (m *Model) PredictProviderWithStateOptions(provider coreml.MLFeatureProvider, state coreml.IMLState, ...) (*Prediction, error)
- func (m *Model) PrepareWithConcurrencyHint(hint int64)
- func (m *Model) Raw() coreml.MLModel
- func (m *Model) SupportsConcurrentSubmissions() bool
- type OutputBackingsVerifier
- func (v OutputBackingsVerifier) VerifyOutputBacking(backing, feature objectivec.IObject) error
- func (v OutputBackingsVerifier) VerifyOutputBackings(backings foundation.INSDictionary, predictionUsesBatch bool) error
- func (v OutputBackingsVerifier) VerifyPixelBufferOutputBacking(backing corevideo.CVImageBufferRef, feature objectivec.IObject) error
- type OutputPortBinder
- func (b OutputPortBinder) Bind() error
- func (b OutputPortBinder) DirectlyBindOutputBacking(backing objectivec.IObject) error
- func (b OutputPortBinder) MakeFeatureValue() (coreml.MLFeatureValue, error)
- func (b OutputPortBinder) MakeFeatureValueFromOutputBacking(backing objectivec.IObject) (coreml.MLFeatureValue, error)
- func (b OutputPortBinder) Raw() privatecoreml.MLE5OutputPortBinder
- func (b OutputPortBinder) Reset()
- func (b OutputPortBinder) ReusableForOutputBacking(backing objectivec.IObject) (reusable bool, direct bool)
- func (b OutputPortBinder) SetOutputBacking(backing objectivec.IObject)
- func (b OutputPortBinder) SetPixelBufferPool(pool PixelBufferPool)
- type PixelBufferPool
- type Prediction
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 ¶
func (b InputPortBinder) Raw() privatecoreml.MLE5InputPortBinder
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 (*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 ¶
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 {
// 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 ¶
func (b OutputPortBinder) Raw() privatecoreml.MLE5OutputPortBinder
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 ¶
func (p PixelBufferPool) Cache() foundation.INSDictionary
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 ¶
func (p PixelBufferPool) Raw() privatecoreml.MLPixelBufferPool
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 ¶
func (p *Prediction) Provider() coreml.MLFeatureProviderObject
Provider returns the retained prediction provider.