NeuralNetworks
Summary
Typedefs |
|
---|---|
ANeuralNetworksBurst
|
typedefstruct ANeuralNetworksBurst
ANeuralNetworksBurst is an opaque type that can be used to reduce the latency of a rapid sequence of executions. |
ANeuralNetworksCompilation
|
typedefstruct ANeuralNetworksCompilation
ANeuralNetworksCompilation is an opaque type that can be used to compile a machine learning model. |
ANeuralNetworksDevice
|
typedefstruct ANeuralNetworksDevice
ANeuralNetworksDevice is an opaque type that represents a device. |
ANeuralNetworksEvent
|
typedefstruct ANeuralNetworksEvent
ANeuralNetworksEvent is an opaque type that represents an event that will be signaled once an execution completes. |
ANeuralNetworksExecution
|
typedefstruct ANeuralNetworksExecution
ANeuralNetworksExecution is an opaque type that can be used to apply a machine learning model to a set of inputs. |
ANeuralNetworksMemory
|
typedefstruct ANeuralNetworksMemory
ANeuralNetworksMemory is an opaque type that represents memory. |
ANeuralNetworksMemoryDesc
|
typedefstruct ANeuralNetworksMemoryDesc
ANeuralNetworksMemoryDesc is an opaque type that represents a memory descriptor. |
ANeuralNetworksModel
|
typedefstruct ANeuralNetworksModel
ANeuralNetworksModel is an opaque type that contains a description of the mathematical operations that constitute the model. |
ANeuralNetworksOperandType
|
typedefstruct ANeuralNetworksOperandType
ANeuralNetworksOperandType describes the type of an operand. |
ANeuralNetworksOperationType
|
typedefint32_t
Aliasing to OperationCode, used in function ANeuralNetworksModel_addOperation. |
ANeuralNetworksSymmPerChannelQuantParams
|
typedef Parameters for ANEURALNETWORKS_TENSOR_QUANT8_SYMM_PER_CHANNEL operand. |
Functions |
|
---|---|
ANeuralNetworksBurst_create(ANeuralNetworksCompilation *compilation, ANeuralNetworksBurst **burst)
|
int
Create a ANeuralNetworksBurst to apply the given compilation. |
ANeuralNetworksBurst_free(ANeuralNetworksBurst *burst)
|
void
Destroys the burst object. |
ANeuralNetworksCompilation_create(ANeuralNetworksModel *model, ANeuralNetworksCompilation **compilation)
|
int
Create a ANeuralNetworksCompilation to compile the given model. |
ANeuralNetworksCompilation_createForDevices(ANeuralNetworksModel *model, const ANeuralNetworksDevice *const *devices, uint32_t numDevices, ANeuralNetworksCompilation **compilation)
|
int
Create a ANeuralNetworksCompilation to compile the given model for a specified set of devices. |
ANeuralNetworksCompilation_finish(ANeuralNetworksCompilation *compilation)
|
int
Indicate that we have finished modifying a compilation. |
ANeuralNetworksCompilation_free(ANeuralNetworksCompilation *compilation)
|
void
Destroy a compilation. |
ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput(const ANeuralNetworksCompilation *compilation, uint32_t index, uint32_t *alignment)
|
int
Get the preferred buffer and memory alignment of an input to an execution created from a particular compilation. |
ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput(const ANeuralNetworksCompilation *compilation, uint32_t index, uint32_t *alignment)
|
int
Get the preferred buffer and memory alignment of an output to an execution created from a particular compilation. |
ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput(const ANeuralNetworksCompilation *compilation, uint32_t index, uint32_t *padding)
|
int
Get the preferred buffer and memory end padding of an input to an execution created from a particular compilation. |
ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput(const ANeuralNetworksCompilation *compilation, uint32_t index, uint32_t *padding)
|
int
Get the preferred memory end padding of an output to an execution created from a particular compilation. |
ANeuralNetworksCompilation_setCaching(ANeuralNetworksCompilation *compilation, const char *cacheDir, const uint8_t *token)
|
int
Sets the compilation caching signature and the cache directory. |
ANeuralNetworksCompilation_setPreference(ANeuralNetworksCompilation *compilation, int32_t preference)
|
int
Sets the execution preference. |
ANeuralNetworksCompilation_setPriority(ANeuralNetworksCompilation *compilation, int priority)
|
int
Set the execution priority. |
ANeuralNetworksCompilation_setTimeout(ANeuralNetworksCompilation *compilation, uint64_t duration)
|
int
Set the maximum expected duration for compiling the model. |
ANeuralNetworksDevice_getFeatureLevel(const ANeuralNetworksDevice *device, int64_t *featureLevel)
|
int
Get the NNAPI feature level of the specified NNAPI device. |
ANeuralNetworksDevice_getName(const ANeuralNetworksDevice *device, const char **name)
|
int
Get the name of the specified device. |
ANeuralNetworksDevice_getType(const ANeuralNetworksDevice *device, int32_t *type)
|
int
Get the type of a given device. |
ANeuralNetworksDevice_getVersion(const ANeuralNetworksDevice *device, const char **version)
|
int
Get the version of the driver implementation of the specified device. |
ANeuralNetworksDevice_wait(const ANeuralNetworksDevice *device)
|
int
Wait until the device is in a live state. |
ANeuralNetworksEvent_createFromSyncFenceFd(int sync_fence_fd, ANeuralNetworksEvent **event)
|
int
Create a ANeuralNetworksEvent from a sync_fence file descriptor. |
ANeuralNetworksEvent_free(ANeuralNetworksEvent *event)
|
void
Destroys the event. |
ANeuralNetworksEvent_getSyncFenceFd(const ANeuralNetworksEvent *event, int *sync_fence_fd)
|
int
Get sync_fence file descriptor from the event. |
ANeuralNetworksEvent_wait(ANeuralNetworksEvent *event)
|
int
Waits until the execution completes. |
ANeuralNetworksExecution_burstCompute(ANeuralNetworksExecution *execution, ANeuralNetworksBurst *burst)
|
int
Schedule synchronous evaluation of the execution on a burst object. |
ANeuralNetworksExecution_compute(ANeuralNetworksExecution *execution)
|
int
Schedule synchronous evaluation of the execution. |
ANeuralNetworksExecution_create(ANeuralNetworksCompilation *compilation, ANeuralNetworksExecution **execution)
|
int
Create a ANeuralNetworksExecution to apply the given compilation. |
ANeuralNetworksExecution_enableInputAndOutputPadding(ANeuralNetworksExecution *execution, bool enable)
|
int
Specifies whether the ANeuralNetworksExecution is able to accept padded input and output buffers and memory objects. |
ANeuralNetworksExecution_free(ANeuralNetworksExecution *execution)
|
void
Destroy an execution. |
ANeuralNetworksExecution_getDuration(const ANeuralNetworksExecution *execution, int32_t durationCode, uint64_t *duration)
|
int
Get the time spent in the latest computation evaluated on the specified ANeuralNetworksExecution, in nanoseconds. |
ANeuralNetworksExecution_getOutputOperandDimensions(ANeuralNetworksExecution *execution, int32_t index, uint32_t *dimensions)
|
int
Get the dimensional information of the specified output operand of the model of the latest computation evaluated on ANeuralNetworksExecution. |
ANeuralNetworksExecution_getOutputOperandRank(ANeuralNetworksExecution *execution, int32_t index, uint32_t *rank)
|
int
Get the dimensional information of the specified output operand of the model of the latest computation evaluated on ANeuralNetworksExecution. |
ANeuralNetworksExecution_setInput(ANeuralNetworksExecution *execution, int32_t index, const ANeuralNetworksOperandType *type, const void *buffer, size_t length)
|
int
Associate a user buffer with an input of the model of the ANeuralNetworksExecution. |
ANeuralNetworksExecution_setInputFromMemory(ANeuralNetworksExecution *execution, int32_t index, const ANeuralNetworksOperandType *type, const ANeuralNetworksMemory *memory, size_t offset, size_t length)
|
int
Associate a region of a memory object with an input of the model of the ANeuralNetworksExecution. |
ANeuralNetworksExecution_setLoopTimeout(ANeuralNetworksExecution *execution, uint64_t duration)
|
int
Set the maximum duration of WHILE loops in the specified execution. |
ANeuralNetworksExecution_setMeasureTiming(ANeuralNetworksExecution *execution, bool measure)
|
int
Specifies whether duration of the ANeuralNetworksExecution is to be measured. |
ANeuralNetworksExecution_setOutput(ANeuralNetworksExecution *execution, int32_t index, const ANeuralNetworksOperandType *type, void *buffer, size_t length)
|
int
Associate a user buffer with an output of the model of the ANeuralNetworksExecution. |
ANeuralNetworksExecution_setOutputFromMemory(ANeuralNetworksExecution *execution, int32_t index, const ANeuralNetworksOperandType *type, const ANeuralNetworksMemory *memory, size_t offset, size_t length)
|
int
Associate a region of a memory object with an output of the model of the ANeuralNetworksExecution. |
ANeuralNetworksExecution_setReusable(ANeuralNetworksExecution *execution, bool reusable)
|
int
Specifies whether the ANeuralNetworksExecution can be reused for multiple computations. |
ANeuralNetworksExecution_setTimeout(ANeuralNetworksExecution *execution, uint64_t duration)
|
int
Set the maximum expected duration of the specified execution. |
ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution *execution, ANeuralNetworksEvent **event)
|
int
Schedule asynchronous evaluation of the execution. |
ANeuralNetworksExecution_startComputeWithDependencies(ANeuralNetworksExecution *execution, const ANeuralNetworksEvent *const *dependencies, uint32_t num_dependencies, uint64_t duration, ANeuralNetworksEvent **event)
|
int
Schedule asynchronous evaluation of the execution with dependencies. |
ANeuralNetworksMemoryDesc_addInputRole(ANeuralNetworksMemoryDesc *desc, const ANeuralNetworksCompilation *compilation, uint32_t index, float frequency)
|
int
Specify that a memory object will be playing the role of an input to an execution created from a particular compilation. |
ANeuralNetworksMemoryDesc_addOutputRole(ANeuralNetworksMemoryDesc *desc, const ANeuralNetworksCompilation *compilation, uint32_t index, float frequency)
|
int
Specify that a memory object will be playing the role of an output to an execution created from a particular compilation. |
ANeuralNetworksMemoryDesc_create(ANeuralNetworksMemoryDesc **desc)
|
int
Create a ANeuralNetworksMemoryDesc with no properties. |
ANeuralNetworksMemoryDesc_finish(ANeuralNetworksMemoryDesc *desc)
|
int
Indicate that we have finished modifying a memory descriptor. |
ANeuralNetworksMemoryDesc_free(ANeuralNetworksMemoryDesc *desc)
|
void
Destroy a memory descriptor. |
ANeuralNetworksMemoryDesc_setDimensions(ANeuralNetworksMemoryDesc *desc, uint32_t rank, const uint32_t *dimensions)
|
int
Set the dimensional information of the memory descriptor. |
ANeuralNetworksMemory_copy(const ANeuralNetworksMemory *src, const ANeuralNetworksMemory *dst)
|
int
Copies data from one memory object to another. |
ANeuralNetworksMemory_createFromAHardwareBuffer(const AHardwareBuffer *ahwb, ANeuralNetworksMemory **memory)
|
int
Creates a shared memory object from an AHardwareBuffer handle. |
ANeuralNetworksMemory_createFromDesc(const ANeuralNetworksMemoryDesc *desc, ANeuralNetworksMemory **memory)
|
int
Creates a memory object from a memory descriptor. |
ANeuralNetworksMemory_createFromFd(size_t size, int protect, int fd, size_t offset, ANeuralNetworksMemory **memory)
|
int
Creates a shared memory object from a file descriptor. |
ANeuralNetworksMemory_free(ANeuralNetworksMemory *memory)
|
void
Delete a memory object. |
ANeuralNetworksModel_addOperand(ANeuralNetworksModel *model, const ANeuralNetworksOperandType *type)
|
int
Add an operand to a model. |
ANeuralNetworksModel_addOperation(ANeuralNetworksModel *model, ANeuralNetworksOperationType type, uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs)
|
int
Add an operation to a model. |
ANeuralNetworksModel_create(ANeuralNetworksModel **model)
|
int
Create an empty ANeuralNetworksModel. |
ANeuralNetworksModel_finish(ANeuralNetworksModel *model)
|
int
Indicate that we have finished modifying a model. |
ANeuralNetworksModel_free(ANeuralNetworksModel *model)
|
void
Destroy a model. |
ANeuralNetworksModel_getSupportedOperationsForDevices(const ANeuralNetworksModel *model, const ANeuralNetworksDevice *const *devices, uint32_t numDevices, bool *supportedOps)
|
int
Get the supported operations for a specified set of devices. |
ANeuralNetworksModel_identifyInputsAndOutputs(ANeuralNetworksModel *model, uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs)
|
int
Specifies which operands will be the model's inputs and outputs. |
ANeuralNetworksModel_relaxComputationFloat32toFloat16(ANeuralNetworksModel *model, bool allow)
|
int
Specifies whether ANEURALNETWORKS_TENSOR_FLOAT32 is allowed to be calculated with range and/or precision as low as that of the IEEE 754 16-bit floating-point format. |
ANeuralNetworksModel_setOperandSymmPerChannelQuantParams(ANeuralNetworksModel *model, int32_t index, const ANeuralNetworksSymmPerChannelQuantParams *channelQuant)
|
int
Sets an operand's per channel quantization parameters. |
ANeuralNetworksModel_setOperandValue(ANeuralNetworksModel *model, int32_t index, const void *buffer, size_t length)
|
int
Sets an operand to a constant value. |
ANeuralNetworksModel_setOperandValueFromMemory(ANeuralNetworksModel *model, int32_t index, const ANeuralNetworksMemory *memory, size_t offset, size_t length)
|
int
Sets an operand to a value stored in a memory object. |
ANeuralNetworksModel_setOperandValueFromModel(ANeuralNetworksModel *model, int32_t index, const ANeuralNetworksModel *value)
|
int
Sets an operand to a value that is a reference to another NNAPI model. |
ANeuralNetworks_getDefaultLoopTimeout()
|
uint64_t
Get the default timeout value for WHILE loops. |
ANeuralNetworks_getDevice(uint32_t devIndex, ANeuralNetworksDevice **device)
|
int
Get the representation of the specified device. |
ANeuralNetworks_getDeviceCount(uint32_t *numDevices)
|
int
Get the number of available devices. |
ANeuralNetworks_getMaximumLoopTimeout()
|
uint64_t
Get the maximum timeout value for WHILE loops. |
ANeuralNetworks_getRuntimeFeatureLevel()
|
int64_t
Get the NNAPI runtime feature level. |
Structs |
|
---|---|
ANeuralNetworksOperandType |
ANeuralNetworksOperandType describes the type of an operand. |
ANeuralNetworksSymmPerChannelQuantParams |
Parameters for ANEURALNETWORKS_TENSOR_QUANT8_SYMM_PER_CHANNEL operand. |
Enumerations
Anonymous Enum 53
Declared inandroid/NeuralNetworksTypes.h
Anonymous Enum 53
For ANeuralNetworksModel_setOperandValue, values with a length smaller or equal to this will be immediately copied into the model.
The size is in bytes.
Available since NNAPI feature level 1.
Properties | |
---|---|
ANEURALNETWORKS_MAX_SIZE_OF_IMMEDIATELY_COPIED_VALUES
|
Anonymous Enum 54
Declared inandroid/NeuralNetworksTypes.h
Anonymous Enum 54
For ANeuralNetworksCompilation_setCaching, specify the size of the cache token required from the application.
The size is in bytes.
Available since NNAPI feature level 3.
Properties | |
---|---|
ANEURALNETWORKS_BYTE_SIZE_OF_CACHE_TOKEN
|
DeviceTypeCode
Declared inandroid/NeuralNetworksTypes.h
DeviceTypeCode
Device types.
The type of NNAPI device.
DurationCode
Declared inandroid/NeuralNetworksTypes.h
DurationCode
FeatureLevelCode
Declared inandroid/NeuralNetworksTypes.h
FeatureLevelCode
NNAPI feature levels.
Each update of the NNAPI specification yields a new NNAPI feature level enum value. NNAPI feature level corrseponds to an NNAPI specification version that a driver and/or the NNAPI runtime can implement.
A feature level up to and including "FEATURE_LEVEL_5" maps directly to the Android API level that introduced the corresponding update of the NNAPI specification. Feature levels after Android API level 31 have no association with API level because the NNAPI specification can be updated between Android API releases. Outputs of ANeuralNetworksDevice_getFeatureLevel and ANeuralNetworks_getRuntimeFeatureLevel must be compared against these enum values instead of the Android API level.
FuseCode
Declared inandroid/NeuralNetworksTypes.h
FuseCode
Fused activation function types.
Available since NNAPI feature level 1.
OperandCode
Declared inandroid/NeuralNetworksTypes.h
OperandCode
Operand types.
The type of an operand in a model.
Types prefaced with ANEURALNETWORKS_TENSOR_* must be used for tensor data (i.e., tensors with at least one dimension). Types not prefaced by ANEURALNETWORKS_TENSOR_* represent scalar values and must have no dimensions.
Although we define many types, most operators accept just a few types. Most used are ANEURALNETWORKS_TENSOR_FLOAT32, ANEURALNETWORKS_TENSOR_QUANT8_ASYMM, and ANEURALNETWORKS_INT32.
Available since NNAPI feature level 1.
Properties | |
---|---|
ANEURALNETWORKS_BOOL
|
An 8 bit boolean scalar value. Values of this operand type are either true or false. A zero value represents false; any other value represents true. Available since NNAPI feature level 3. |
ANEURALNETWORKS_FLOAT16
|
An IEEE 754 16 bit floating point scalar value. Available since NNAPI feature level 3. |
ANEURALNETWORKS_FLOAT32
|
A 32 bit floating point scalar value. |
ANEURALNETWORKS_INT32
|
A signed 32 bit integer scalar value. |
ANEURALNETWORKS_MODEL
|
A reference to a model. ANeuralNetworksModel_setOperandValueFromModel must be used to set the value for an Operand of this type. Available since NNAPI feature level 4. |
ANEURALNETWORKS_TENSOR_BOOL8
|
A tensor of 8 bit boolean values. Values of this operand type are either true or false. A zero value represents false; any other value represents true. Available since NNAPI feature level 3. |
ANEURALNETWORKS_TENSOR_FLOAT16
|
A tensor of IEEE 754 16 bit floating point values. Available since NNAPI feature level 3. |
ANEURALNETWORKS_TENSOR_FLOAT32
|
A tensor of 32 bit floating point values. |
ANEURALNETWORKS_TENSOR_INT32
|
A tensor of 32 bit integer values. |
ANEURALNETWORKS_TENSOR_QUANT16_ASYMM
|
A tensor of 16 bit unsigned integers that represent real numbers. Attached to this tensor are two numbers that can be used to convert the 16 bit integer to the real value and vice versa. These two numbers are:
The formula is: real_value = (integer_value - zeroPoint) * scale. Available since NNAPI feature level 3. |
ANEURALNETWORKS_TENSOR_QUANT16_SYMM
|
A tensor of 16 bit signed integers that represent real numbers. Attached to this tensor is a number representing real value scale that is used to convert the 16 bit number to a real value in the following way: realValue = integerValue * scale. scale is a 32 bit floating point with value greater than zero. Available since NNAPI feature level 3. |
ANEURALNETWORKS_TENSOR_QUANT8_ASYMM
|
A tensor of 8 bit unsigned integers that represent real numbers. Attached to this tensor are two numbers that can be used to convert the 8 bit integer to the real value and vice versa. These two numbers are:
The formula is: real_value = (integer_value - zeroPoint) * scale. |
ANEURALNETWORKS_TENSOR_QUANT8_ASYMM_SIGNED
|
A tensor of 8 bit signed integers that represent real numbers. Attached to this tensor are two numbers that can be used to convert the 8 bit integer to the real value and vice versa. These two numbers are:
The formula is: real_value = (integer_value - zeroPoint) * scale. Available since NNAPI feature level 4. |
ANEURALNETWORKS_TENSOR_QUANT8_SYMM
|
A tensor of 8 bit signed integers that represent real numbers. Attached to this tensor is a number representing real value scale that is used to convert the 8 bit number to a real value in the following way: realValue = integerValue * scale. scale is a 32 bit floating point with value greater than zero. Available since NNAPI feature level 3. |
ANEURALNETWORKS_TENSOR_QUANT8_SYMM_PER_CHANNEL
|
A tensor of 8 bit signed integers that represent real numbers. This tensor is associated with additional fields that can be used to convert the 8 bit signed integer to the real value and vice versa. These fields are:
ANeuralNetworksModel_setOperandSymmPerChannelQuantParams must be used to set the parameters for an Operand of this type. The channel dimension of this tensor must not be unknown (dimensions[channelDim] != 0). The formula is: realValue[..., C, ...] = integerValue[..., C, ...] * scales[C] where C is an index in the Channel dimension. Available since NNAPI feature level 3. |
ANEURALNETWORKS_UINT32
|
An unsigned 32 bit integer scalar value. |
OperationCode
Declared inandroid/NeuralNetworksTypes.h
OperationCode
Operation types.
The type of an operation in a model.
Available since NNAPI feature level 1.
Properties | |
---|---|
ANEURALNETWORKS_ABS
|
Computes the absolute value of a tensor, element-wise. Supported tensor OperandCode:
Supported tensor rank: from 1. Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_ADD
|
Adds two tensors, element-wise. Takes two input tensors of identical OperandCode and compatible dimensions. The output is the sum of both input tensors, optionally modified by an activation function. Two dimensions are compatible when:
The size of the output is the maximum size along each dimension of the input operands. It starts with the trailing dimensions, and works its way forward. Example: input1.dimension = {4, 1, 2} input2.dimension = {5, 4, 3, 1} output.dimension = {5, 4, 3, 2} Since NNAPI feature level 3, generic zero-sized input tensor is supported. Zero dimension is only compatible with 0 or 1. The size of the output dimension is zero if either of corresponding input dimension is zero. Supported tensor OperandCode:
Supported tensor rank: up to 4 Inputs:
Outputs:
Available since NNAPI feature level 1. |
ANEURALNETWORKS_ARGMAX
|
Returns the index of the largest element along an axis. Supported tensor OperandCode:
Supported tensor rank: from 1 Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_ARGMIN
|
Returns the index of the smallest element along an axis. Supported tensor OperandCode:
Supported tensor rank: from 1 Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_AVERAGE_POOL_2D
|
Performs a 2-D average pooling operation. The output dimensions are functions of the filter dimensions, stride, and padding. The values in the output tensor are computed as: output[b, i, j, channel] =
sum_{di, dj}(
input[b, strides[1] * i + di, strides[2] * j + dj, channel]
) / sum(1) Supported tensor OperandCode:
Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. With the default data layout NHWC, the data is stored in the order of: [batch, height, width, channels]. Alternatively, the data layout could be NCHW, the data storage order of: [batch, channels, height, width]. NCHW is supported since NNAPI feature level 3. Both explicit padding and implicit padding are supported. Inputs (explicit padding):
Inputs (implicit padding):
Outputs:
Available since NNAPI feature level 1. |
ANEURALNETWORKS_AXIS_ALIGNED_BBOX_TRANSFORM
|
Transform axis-aligned bounding box proposals using bounding box deltas. Given the positions of bounding box proposals and the corresponding bounding box deltas for each class, return the refined bounding box regions. The resulting bounding boxes are cliped against the edges of the image. Supported tensor OperandCode: Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_BATCH_MATMUL
|
Performs multiplication of two tensors in batches. Multiplies all slices of two input tensors and arranges the individual results in a single output tensor of the same batch size. Each pair of slices in the same batch have identical OperandCode. Each slice can optionally be adjointed (transpose and conjugate) before multiplication. The two input tensors and the output tensor must be 2-D or higher and have the same batch size. Supported tensor OperandCode:
Supported tensor rank: at least 2 and up to 4 Inputs:
Outputs:
Available since NNAPI feature level 6. |
ANEURALNETWORKS_BATCH_TO_SPACE_ND
|
BatchToSpace for N-dimensional tensors. This operation reshapes the batch dimension (dimension 0) into M + 1 dimensions of shape block_shape + [batch], interleaves these blocks back into the grid defined by the spatial dimensions [1, ..., M], to obtain a result with the same rank as the input. This is the reverse of SpaceToBatch. Supported tensor OperandCode:
Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. With the default data layout NHWC, the data is stored in the order of: [batch, height, width, channels]. Alternatively, the data layout could be NCHW, the data storage order of: [batch, channels, height, width]. NCHW is supported since NNAPI feature level 3. Inputs:
Outputs:
Available since NNAPI feature level 2. |
ANEURALNETWORKS_BIDIRECTIONAL_SEQUENCE_LSTM
|
A recurrent neural network layer that applies an LSTM cell to a sequence of inputs in forward and backward directions. The op supports cross-linking via an auxiliary input. Regular cell feeds one input into the two RNN cells in the following way: INPUT (INPUT_REVERSED) | | | FW_LSTM BW_LSTM || | FW_OUT BW_OUT An op with cross-linking takes two inputs and feeds them into the RNN cells in the following way: AUX_INPUT (AUX_INPUT_REVERSED) | | INPUT | (INPUT_R'D.)| | | | | | \ / \ / | | FW_LSTM BW_LSTM || | FW_OUT BW_OUT The cross-linking mode is enabled iff auxiliary input and auxiliary weights are present. While stacking this op on top of itself, this allows to connect both forward and backward outputs from previous cell to the next cell's input. Since NNAPI feature level 4 parallel linking mode is supported. The mode is enabled if auxiliary input is present but auxiliary weights are omitted. In this case, the cell feeds inputs into the RNN in the following way: INPUT (AUX_INPUT_REVERSED) | | | FW_LSTM BW_LSTM || | FW_OUT BW_OUT While stacking this op on top of itself, this allows to connect both forward and backward outputs from previous cell to the next cell's corresponding inputs. Supported tensor OperandCode: Supported tensor rank: 3, either time-major or batch-major. All input and output tensors must be of the same type. Inputs:
Outputs:
Available since NNAPI feature level 3. Important: As of NNAPI feature level 3, there is no way to get the output state tensors out and NNAPI does not maintain internal states. This operator does not support the usage pattern in which multiple cells are chained and state tensors are propagated. |
ANEURALNETWORKS_BIDIRECTIONAL_SEQUENCE_RNN
|
A recurrent neural network layer that applies a basic RNN cell to a sequence of inputs in forward and backward directions. This Op unrolls the input along the sequence dimension, and implements the following operation for each element in the sequence s = 1...sequence_length: fw_outputs[s] = fw_state = activation(inputs[s] * fw_input_weights’ + fw_state * fw_recurrent_weights’ + fw_bias) And for each element in sequence t = sequence_length : 1 bw_outputs[t] = bw_state = activation(inputs[t] * bw_input_weights’ + bw_state * bw_recurrent_weights’ + bw_bias) Where:
The op supports cross-linking via an auxiliary input. Regular cell feeds one input into the two RNN cells in the following way: INPUT (INPUT_REVERSED) | | | FW_RNN BW_RNN || | FW_OUT BW_OUT An op with cross-linking takes two inputs and feeds them into the RNN cells in the following way: AUX_INPUT (AUX_INPUT_REVERSED) | | INPUT | (INPUT_R'D.)| | | | | | \ / \ / | | FW_RNN BW_RNN || | FW_OUT BW_OUT The cross-linking mode is enabled iff auxiliary input and auxiliary weights are present. While stacking this op on top of itself, this allows to connect both forward and backward outputs from previous cell to the next cell's input. Since NNAPI feature level 4 parallel linking mode is supported. The mode is enabled if auxiliary input is present but auxiliary weights are omitted. In this case, the cell feeds inputs into the RNN in the following way: INPUT (AUX_INPUT_REVERSED) | | | FW_RNN BW_RNN || | FW_OUT BW_OUT While stacking this op on top of itself, this allows to connect both forward and backward outputs from previous cell to the next cell's corresponding inputs. Supported tensor OperandCode: The input tensors must all be the same type. Inputs:
Available since NNAPI feature level 3. Important: As of NNAPI feature level 3, there is no way to get the output state tensors out and NNAPI does not maintain internal states. This operator does not support the usage pattern in which multiple cells are chained and state tensors are propagated. |
ANEURALNETWORKS_BOX_WITH_NMS_LIMIT
|
Greedily selects a subset of bounding boxes in descending order of score. This op applies NMS algorithm to each class. In each loop of execution, the box with maximum score gets selected and removed from the pending set. The scores of the rest of boxes are lowered according to the intersection-over-union (IOU) overlapping with the previously selected boxes and a specified NMS kernel method. Any boxes with score less than a threshold are removed from the pending set. Three NMS kernels are supported:
Axis-aligned bounding boxes are represented by its upper-left corner coordinate (x1,y1) and lower-right corner coordinate (x2,y2). A valid bounding box should satisfy x1 <= x2 and y1 <= y2. Supported tensor OperandCode:
Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_CAST
|
Casts a tensor to a type. This operation ignores the scale and zeroPoint of quanized tensors, e.g. it treats a ANEURALNETWORKS_TENSOR_QUANT8_ASYMM input as a tensor of uint8 values. Supported tensor OperandCode:
Supported tensor rank: from 1 Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_CHANNEL_SHUFFLE
|
Shuffle the channels of the input tensor. Given an input tensor and a integer value of num_groups, CHANNEL_SHUFFLE divide the channel dimension into num_groups groups, and reorganize the channels by grouping channels with the same index in each group. Along the channel dimension, the output is calculated using this formula: output_channel[k * num_groups + g] = input_channel[g * group_size + k] where group_size = num_channels / num_groups The number of channels must be divisible by num_groups. Supported tensor OperandCode:
Supported tensor rank: up to 4 Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_CONCATENATION
|
Concatenates the input tensors along the given dimension. The input tensors must have identical OperandCode and the same dimensions except the dimension along the concatenation axis. Supported tensor OperandCode:
Supported tensor rank: up to 4 Inputs:
Outputs:
Available since NNAPI feature level 1. |
ANEURALNETWORKS_CONV_2D
|
Performs a 2-D convolution operation. The CONV_2D op sweeps a 2-D filter that can mix channels together over a batch of images, applying the filter to each window of each image of the appropriate size. The output dimensions are functions of the filter dimensions, stride, and padding. The values in the output tensor are computed as: output[b, i, j, channel] = sum_{di, dj, k} ( input[b, strides[1] * i + di, strides[2] * j + dj, k] * filter[channel, di, dj, k] ) + bias[channel] Supported tensor OperandCode configurations:
Available since NNAPI feature level 3:
Available since NNAPI feature level 4:
Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. With the default data layout NHWC, the data is stored in the order of: [batch, height, width, channels]. Alternatively, the data layout could be NCHW, the data storage order of: [batch, channels, height, width]. NCHW is supported since NNAPI feature level 3. Both explicit padding and implicit padding are supported. Inputs (explicit padding):
Inputs (implicit padding):
Outputs:
Available since NNAPI feature level 1. |
ANEURALNETWORKS_DEPTHWISE_CONV_2D
|
Performs a depthwise 2-D convolution operation. Given an input tensor of shape [batches, height, width, depth_in] and a filter tensor of shape [1, filter_height, filter_width, depth_out] containing depth_out convolutional filters of depth 1, DEPTHWISE_CONV applies a different filter to each input channel (expanding from 1 channel to channel_multiplier channels for each), then concatenates the results together. The output has depth_out = depth_in * depth_multiplier channels. The output dimensions are functions of the filter dimensions, stride, and padding. The values in the output tensor are computed as: output[b, i, j, k * channel_multiplier + q] = sum_{di, dj} ( input[b, strides[1] * i + di, strides[2] * j + dj, k] * filter[1, di, dj, k * channel_multiplier + q] ) + bias[k * channel_multiplier + q] Supported tensor OperandCode configurations:
Available since NNAPI feature level 3:
Available since NNAPI feature level 4:
Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. With the default data layout NHWC, the data is stored in the order of: [batch, height, width, channels]. Alternatively, the data layout could be NCHW, the data storage order of: [batch, channels, height, width]. NCHW is supported since NNAPI feature level 3. Both explicit padding and implicit padding are supported. Inputs (explicit padding):
Inputs (implicit padding):
Outputs:
Available since NNAPI feature level 1. |
ANEURALNETWORKS_DEPTH_TO_SPACE
|
Rearranges data from depth into blocks of spatial data. More specifically, this op outputs a copy of the input tensor where values from the depth dimension are moved in spatial blocks to the height and width dimensions. The value block_size indicates the input block size and how the data is moved. Chunks of data of size block_size * block_size from depth are rearranged into non-overlapping blocks of size block_size x block_size. The width of the output tensor is input_depth * block_size, whereas the height is input_height * block_size. The depth of the input tensor must be divisible by block_size * block_size Supported tensor OperandCode:
Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. With the default data layout NHWC, the data is stored in the order of: [batch, height, width, channels]. Alternatively, the data layout could be NCHW, the data storage order of: [batch, channels, height, width]. NCHW is supported since NNAPI feature level 3. Inputs:
Outputs:
Available since NNAPI feature level 1. |
ANEURALNETWORKS_DEQUANTIZE
|
Dequantizes the input tensor. The formula is: output = (input - zeroPoint) * scale. Supported input tensor OperandCode:
Supported output tensor OperandCode:
Supported tensor rank: up to 4 Inputs:
Outputs:
Available since NNAPI feature level 1. |
ANEURALNETWORKS_DETECTION_POSTPROCESSING
|
Apply postprocessing steps to bounding box detections. Bounding box detections are generated by applying transformation on a set of predefined anchors with the bounding box deltas from bounding box regression. A final step of hard NMS is applied to limit the number of returned boxes. Supported tensor OperandCode: Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_DIV
|
Element-wise division of two tensors. Takes two input tensors of identical OperandCode and compatible dimensions. The output is the result of dividing the first input tensor by the second, optionally modified by an activation function. For inputs of ANEURALNETWORKS_TENSOR_INT32, performs "floor division" ("//" in Python). For example, 5 // 2 = 2 -5 // 2 = -3 Two dimensions are compatible when:
The size of the output is the maximum size along each dimension of the input operands. It starts with the trailing dimensions, and works its way forward. Example: input1.dimension = {4, 1, 2} input2.dimension = {5, 4, 3, 1} output.dimension = {5, 4, 3, 2} Since NNAPI feature level 3, generic zero-sized input tensor is supported. Zero dimension is only compatible with 0 or 1. The size of the output dimension is zero if either of corresponding input dimension is zero. Supported tensor OperandCode:
Supported tensor rank: up to 4 Inputs:
Outputs:
Available since NNAPI feature level 2. |
ANEURALNETWORKS_ELU
|
Computes exponential linear activation on the input tensor element-wise. The output is calculated using the following formula: ELU(x) = max(0, x) + min(0, alpha * (exp(x) - 1)) Supported tensor OperandCode: Supported tensor rank: from 1. Inputs:
Outputs:
Available since NNAPI feature level 4. |
ANEURALNETWORKS_EMBEDDING_LOOKUP
|
Looks up sub-tensors in the input tensor. This operator takes for input a tensor of values (Values) and a one-dimensional tensor of selection indices (Lookups). The output tensor is the concatenation of sub-tensors of Values as selected by Lookups. Think of Values as being sliced along its first dimension: The entries in Lookups select which slices are concatenated together to create the output tensor. For example, if Values has shape of [40, 200, 300] and Lookups has shape of [3], all three values found in Lookups are expected to be between 0 and 39. The resulting tensor must have shape of [3, 200, 300]. If a value in Lookups is out of bounds, the operation must fail and an error must be reported. Supported value tensor OperandCode:
Supported value tensor rank: from 2 Inputs:
Output:
Available since NNAPI feature level 1. |
ANEURALNETWORKS_EQUAL
|
For input tensors x and y, computes x == y elementwise. Supported tensor OperandCode:
Supported tensor rank: from 1 This operation supports broadcasting. Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_EXP
|
Computes exponential of x element-wise. Supported tensor OperandCode: Supported tensor rank: from 1. Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_EXPAND_DIMS
|
Inserts a dimension of 1 into a tensor's shape. Given a tensor input, this operation inserts a dimension of 1 at the given dimension index of input's shape. The dimension index starts at zero; if you specify a negative dimension index, it is counted backward from the end. Supported tensor OperandCode:
Supported tensor rank: from 1 Inputs:
Outputs:
Available since NNAPI feature level 3. |
ANEURALNETWORKS_FILL
|
Creates a tensor filled with a scalar value. Supported output tensor OperandCode: Supported tensor rank: from 1. Inputs:
Outputs:
Available since NNAPI feature level 4. |
ANEURALNETWORKS_FLOOR
|
Computes element-wise floor() on the input tensor. Supported tensor |