Documentation
¶
Overview ¶
Package nnapi provides Go bindings for Android Neural Networks API (NNAPI).
Index ¶
- func ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput(compilation *Compilation, index uint32, alignment *uint32) int32
- func ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput(compilation *Compilation, index uint32, alignment *uint32) int32
- func ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput(compilation *Compilation, index uint32, padding *uint32) int32
- func ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput(compilation *Compilation, index uint32, padding *uint32) int32
- func ANeuralNetworksDevice_wait(device *Device) int32
- func ANeuralNetworksEvent_getSyncFenceFd(event *Event, sync_fence_fd *int32) int32
- func ANeuralNetworksExecution_burstCompute(execution *Execution, burst *Burst) int32
- func ANeuralNetworksExecution_enableInputAndOutputPadding(execution *Execution, enable bool) int32
- func ANeuralNetworksExecution_getOutputOperandDimensions(execution *Execution, index int32, dimensions *uint32) int32
- func ANeuralNetworksExecution_getOutputOperandRank(execution *Execution, index int32, rank *uint32) int32
- func ANeuralNetworksExecution_setLoopTimeout(execution *Execution, duration uint64) int32
- func ANeuralNetworksExecution_setReusable(execution *Execution, reusable bool) int32
- func ANeuralNetworksMemoryDesc_addInputRole(desc *ANeuralNetworksMemoryDesc, compilation *Compilation, index uint32, ...) int32
- func ANeuralNetworksMemoryDesc_addOutputRole(desc *ANeuralNetworksMemoryDesc, compilation *Compilation, index uint32, ...) int32
- func ANeuralNetworksMemoryDesc_finish(desc *ANeuralNetworksMemoryDesc) int32
- func ANeuralNetworksMemoryDesc_free(desc *ANeuralNetworksMemoryDesc)
- func ANeuralNetworksMemoryDesc_setDimensions(desc *ANeuralNetworksMemoryDesc, rank uint32, dimensions *uint32) int32
- func ANeuralNetworksMemory_copy(src *Memory, dst *Memory) int32
- func ANeuralNetworksModel_setOperandSymmPerChannelQuantParams(model *Model, index int32, ...) int32
- func ANeuralNetworksModel_setOperandValueFromMemory(model *Model, index int32, memory *Memory, offset uint64, length uint64) int32
- func ANeuralNetworksModel_setOperandValueFromModel(model *Model, index int32, value *Model) int32
- func ANeuralNetworks_getDefaultLoopTimeout() uint64
- func ANeuralNetworks_getMaximumLoopTimeout() uint64
- func ANeuralNetworks_getRuntimeFeatureLevel() int64
- type AHardwareBuffer
- type ANeuralNetworksMemoryDesc
- type ANeuralNetworksOperationType
- type ANeuralNetworksSymmPerChannelQuantParams
- type Burst
- type Compilation
- func (h *Compilation) Close() error
- func (h *Compilation) Finish() error
- func (h *Compilation) NewBurst() (*Burst, error)
- func (h *Compilation) NewExecution() (*Execution, error)
- func (h *Compilation) Pointer() unsafe.Pointer
- func (h *Compilation) SetCaching(cacheDir string, token *uint8) error
- func (h *Compilation) SetPreference(preference Preference) error
- func (h *Compilation) SetPriority(priority int32) error
- func (h *Compilation) SetTimeout(duration uint64) error
- type Device
- type Error
- type Event
- type Execution
- func (h *Execution) Compute() error
- func (h *Execution) GetDuration(durationCode int32, duration *uint64) error
- func (h *Execution) Pointer() unsafe.Pointer
- func (h *Execution) SetMeasureTiming(measure bool) error
- func (h *Execution) SetTimeout(duration uint64) error
- func (h *Execution) StartCompute() (*Event, error)
- type FuseCode
- type Memory
- type Model
- func (h *Model) AddOperand(desc OperandTypeDesc) error
- func (h *Model) AddOperation(_type ANeuralNetworksOperationType, inputCount uint32, inputs *uint32, ...) error
- func (h *Model) Close() error
- func (h *Model) Finish() error
- func (h *Model) IdentifyInputsAndOutputs(inputCount uint32, inputs *uint32, outputCount uint32, outputs *uint32) error
- func (h *Model) NewCompilation() (*Compilation, error)
- func (h *Model) Pointer() unsafe.Pointer
- func (h *Model) RelaxFloat32toFloat16(allow bool) error
- func (h *Model) SetOperandValue(index int32, buffer unsafe.Pointer, length uint64) error
- type OperandType
- type OperandTypeDesc
- type OperationType
- type Preference
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput ¶
func ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput(compilation *Compilation, index uint32, alignment *uint32) int32
ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput calls the underlying C function.
func ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput ¶
func ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput(compilation *Compilation, index uint32, alignment *uint32) int32
ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput calls the underlying C function.
func ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput ¶
func ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput(compilation *Compilation, index uint32, padding *uint32) int32
ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput calls the underlying C function.
func ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput ¶
func ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput(compilation *Compilation, index uint32, padding *uint32) int32
ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput calls the underlying C function.
func ANeuralNetworksDevice_wait ¶
ANeuralNetworksDevice_wait calls the underlying C function.
func ANeuralNetworksEvent_getSyncFenceFd ¶
ANeuralNetworksEvent_getSyncFenceFd calls the underlying C function.
func ANeuralNetworksExecution_burstCompute ¶
ANeuralNetworksExecution_burstCompute calls the underlying C function.
func ANeuralNetworksExecution_enableInputAndOutputPadding ¶
ANeuralNetworksExecution_enableInputAndOutputPadding calls the underlying C function.
func ANeuralNetworksExecution_getOutputOperandDimensions ¶
func ANeuralNetworksExecution_getOutputOperandDimensions(execution *Execution, index int32, dimensions *uint32) int32
ANeuralNetworksExecution_getOutputOperandDimensions calls the underlying C function.
func ANeuralNetworksExecution_getOutputOperandRank ¶
func ANeuralNetworksExecution_getOutputOperandRank(execution *Execution, index int32, rank *uint32) int32
ANeuralNetworksExecution_getOutputOperandRank calls the underlying C function.
func ANeuralNetworksExecution_setLoopTimeout ¶
ANeuralNetworksExecution_setLoopTimeout calls the underlying C function.
func ANeuralNetworksExecution_setReusable ¶
ANeuralNetworksExecution_setReusable calls the underlying C function.
func ANeuralNetworksMemoryDesc_addInputRole ¶
func ANeuralNetworksMemoryDesc_addInputRole(desc *ANeuralNetworksMemoryDesc, compilation *Compilation, index uint32, frequency float32) int32
ANeuralNetworksMemoryDesc_addInputRole calls the underlying C function.
func ANeuralNetworksMemoryDesc_addOutputRole ¶
func ANeuralNetworksMemoryDesc_addOutputRole(desc *ANeuralNetworksMemoryDesc, compilation *Compilation, index uint32, frequency float32) int32
ANeuralNetworksMemoryDesc_addOutputRole calls the underlying C function.
func ANeuralNetworksMemoryDesc_finish ¶
func ANeuralNetworksMemoryDesc_finish(desc *ANeuralNetworksMemoryDesc) int32
ANeuralNetworksMemoryDesc_finish calls the underlying C function.
func ANeuralNetworksMemoryDesc_free ¶
func ANeuralNetworksMemoryDesc_free(desc *ANeuralNetworksMemoryDesc)
ANeuralNetworksMemoryDesc_free calls the underlying C function.
func ANeuralNetworksMemoryDesc_setDimensions ¶
func ANeuralNetworksMemoryDesc_setDimensions(desc *ANeuralNetworksMemoryDesc, rank uint32, dimensions *uint32) int32
ANeuralNetworksMemoryDesc_setDimensions calls the underlying C function.
func ANeuralNetworksMemory_copy ¶
ANeuralNetworksMemory_copy calls the underlying C function.
func ANeuralNetworksModel_setOperandSymmPerChannelQuantParams ¶
func ANeuralNetworksModel_setOperandSymmPerChannelQuantParams(model *Model, index int32, channelQuant *ANeuralNetworksSymmPerChannelQuantParams) int32
ANeuralNetworksModel_setOperandSymmPerChannelQuantParams calls the underlying C function.
func ANeuralNetworksModel_setOperandValueFromMemory ¶
func ANeuralNetworksModel_setOperandValueFromMemory(model *Model, index int32, memory *Memory, offset uint64, length uint64) int32
ANeuralNetworksModel_setOperandValueFromMemory calls the underlying C function.
func ANeuralNetworksModel_setOperandValueFromModel ¶
ANeuralNetworksModel_setOperandValueFromModel calls the underlying C function.
func ANeuralNetworks_getDefaultLoopTimeout ¶
func ANeuralNetworks_getDefaultLoopTimeout() uint64
ANeuralNetworks_getDefaultLoopTimeout calls the underlying C function.
func ANeuralNetworks_getMaximumLoopTimeout ¶
func ANeuralNetworks_getMaximumLoopTimeout() uint64
ANeuralNetworks_getMaximumLoopTimeout calls the underlying C function.
func ANeuralNetworks_getRuntimeFeatureLevel ¶
func ANeuralNetworks_getRuntimeFeatureLevel() int64
ANeuralNetworks_getRuntimeFeatureLevel calls the underlying C function.
Types ¶
type AHardwareBuffer ¶
type AHardwareBuffer = capi.AHardwareBuffer
type ANeuralNetworksMemoryDesc ¶
type ANeuralNetworksMemoryDesc = capi.ANeuralNetworksMemoryDesc
type ANeuralNetworksOperationType ¶
type ANeuralNetworksOperationType = capi.ANeuralNetworksOperationType
type ANeuralNetworksSymmPerChannelQuantParams ¶
type ANeuralNetworksSymmPerChannelQuantParams = capi.ANeuralNetworksSymmPerChannelQuantParams
type Burst ¶
type Burst struct {
// contains filtered or unexported fields
}
Burst wraps the NDK ANeuralNetworksBurst handle.
func NewBurstFromPointer ¶
NewBurstFromPointer wraps a raw ANeuralNetworksBurst pointer.
type Compilation ¶
type Compilation struct {
// contains filtered or unexported fields
}
Compilation wraps the NDK ANeuralNetworksCompilation handle.
func NewCompilationFromPointer ¶
func NewCompilationFromPointer(ptr unsafe.Pointer) *Compilation
NewCompilationFromPointer wraps a raw ANeuralNetworksCompilation pointer.
func (*Compilation) Close ¶
func (h *Compilation) Close() error
Close releases the underlying NDK handle.
func (*Compilation) Finish ¶
func (h *Compilation) Finish() error
Finish calls the underlying NDK function.
func (*Compilation) NewBurst ¶
func (h *Compilation) NewBurst() (*Burst, error)
NewBurst creates a new Burst from this Compilation.
func (*Compilation) NewExecution ¶
func (h *Compilation) NewExecution() (*Execution, error)
NewExecution creates a new Execution from this Compilation.
func (*Compilation) Pointer ¶
func (h *Compilation) Pointer() unsafe.Pointer
Pointer returns the underlying pointer as unsafe.Pointer.
func (*Compilation) SetCaching ¶
func (h *Compilation) SetCaching(cacheDir string, token *uint8) error
SetCaching calls the underlying NDK function.
func (*Compilation) SetPreference ¶
func (h *Compilation) SetPreference(preference Preference) error
SetPreference calls the underlying NDK function.
func (*Compilation) SetPriority ¶
func (h *Compilation) SetPriority(priority int32) error
SetPriority calls the underlying NDK function.
func (*Compilation) SetTimeout ¶
func (h *Compilation) SetTimeout(duration uint64) error
SetTimeout calls the underlying NDK function.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device wraps the NDK ANeuralNetworksDevice handle.
func NewDeviceFromPointer ¶
NewDeviceFromPointer wraps a raw ANeuralNetworksDevice pointer.
type Error ¶
type Error int32
Error represents an NDK error code.
const ( ErrOutOfMemory Error = 1 ErrIncomplete Error = 2 ErrUnexpectedNull Error = 3 ErrBadData Error = 4 ErrOpFailed Error = 5 ErrBadState Error = 6 ErrUnmappable Error = 7 ErrOutputInsufficientSize Error = 8 ErrMissedDeadlineTransient Error = 10 ErrMissedDeadlinePersistent Error = 11 ErrResourceExhaustedTransient Error = 12 ErrResourceExhaustedPersistent Error = 13 ErrDeadObject Error = 14 )
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event wraps the NDK ANeuralNetworksEvent handle.
func NewEventFromPointer ¶
NewEventFromPointer wraps a raw ANeuralNetworksEvent pointer.
type Execution ¶
type Execution struct {
// contains filtered or unexported fields
}
Execution wraps the NDK ANeuralNetworksExecution handle.
func NewExecutionFromPointer ¶
NewExecutionFromPointer wraps a raw ANeuralNetworksExecution pointer.
func (*Execution) GetDuration ¶
GetDuration calls the underlying NDK function.
func (*Execution) SetMeasureTiming ¶
SetMeasureTiming calls the underlying NDK function.
func (*Execution) SetTimeout ¶
SetTimeout calls the underlying NDK function.
func (*Execution) StartCompute ¶
StartCompute creates a new Event from this Execution.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory wraps the NDK ANeuralNetworksMemory handle.
func NewMemoryFromPointer ¶
NewMemoryFromPointer wraps a raw ANeuralNetworksMemory pointer.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model wraps the NDK ANeuralNetworksModel handle.
func NewModelFromPointer ¶
NewModelFromPointer wraps a raw ANeuralNetworksModel pointer.
func (*Model) AddOperand ¶
func (h *Model) AddOperand(desc OperandTypeDesc) error
AddOperand adds an operand to the model with the given type descriptor.
func (*Model) AddOperation ¶
func (h *Model) AddOperation(_type ANeuralNetworksOperationType, inputCount uint32, inputs *uint32, outputCount uint32, outputs *uint32) error
AddOperation calls the underlying NDK function.
func (*Model) IdentifyInputsAndOutputs ¶
func (h *Model) IdentifyInputsAndOutputs(inputCount uint32, inputs *uint32, outputCount uint32, outputs *uint32) error
IdentifyInputsAndOutputs calls the underlying NDK function.
func (*Model) NewCompilation ¶
func (h *Model) NewCompilation() (*Compilation, error)
NewCompilation creates a new Compilation from this Model.
func (*Model) RelaxFloat32toFloat16 ¶
RelaxFloat32toFloat16 calls the underlying NDK function.
type OperandType ¶
type OperandType int32
const ( Float32 OperandType = 0 Int32 OperandType = 1 Uint32 OperandType = 2 TensorFloat32 OperandType = 3 TensorInt32 OperandType = 4 TensorQuant8Asymm OperandType = 5 Bool OperandType = 6 TensorQuant16Symm OperandType = 7 TensorFloat16 OperandType = 8 TensorBool8 OperandType = 9 Float16 OperandType = 10 TensorQuant8SymmPerChannel OperandType = 11 TensorQuant16Asymm OperandType = 12 TensorQuant8Symm OperandType = 13 TensorQuant8AsymmSigned OperandType = 14 )
type OperandTypeDesc ¶
type OperandTypeDesc struct {
Type OperandType
Dims []uint32
Scale float32
ZeroPoint int32
}
OperandTypeDesc describes the type of an operand for AddOperand. It mirrors the C struct ANeuralNetworksOperandType.
type OperationType ¶
type OperationType int32
const ( Add OperationType = 0 Mul OperationType = 18 Relu OperationType = 19 Softmax OperationType = 25 FullyConnected OperationType = 9 Conv2d OperationType = 3 DepthwiseConv2d OperationType = 4 AveragePool2d OperationType = 1 MaxPool2d OperationType = 17 Reshape OperationType = 22 Concatenation OperationType = 2 )
type Preference ¶
type Preference int32
const ( LowPower Preference = 0 FastSingleAnswer Preference = 1 SustainedSpeed Preference = 2 )
Source Files
¶
- ahardware_buffer.go
- aneural_networks_memory_desc.go
- aneural_networks_operation_type.go
- aneural_networks_symm_per_channel_quant_params.go
- burst.go
- compilation.go
- compilation_close.go
- device.go
- errors.go
- event.go
- execution.go
- functions.go
- fuse_code.go
- memory.go
- model.go
- model_add_operand.go
- model_create.go
- operand_type.go
- operation_type.go
- package.go
- preference.go