ANeuralNetworksOperandType
#include <NeuralNetworksTypes.h>
ANeuralNetworksOperandType describes the type of an operand.
Summary
This structure is used to describe both scalars and tensors.
A tensor operand type with all dimensions specified is "fully specified". Whenever possible (i.e., whenever the dimensions are known at model construction time), a tensor operand type should be (but is not required to be) fully specified, in order to enable the best possible performance.
If a tensor operand's type is not fully specified, the dimensions of the operand are deduced from the operand types and values of the operation for which that operand is an output or from the corresponding ANEURALNETWORKS_IF or ANEURALNETWORKS_WHILE operation input operand type in the case of referenced model input operands.
In the following situations, a tensor operand type must be fully specified:
- The operand has a constant value, set by ANeuralNetworksModel_setOperandValue (with a non-nullptr buffer) or ANeuralNetworksModel_setOperandValueFromMemory.
- The operand is a model input (see ANeuralNetworksModel_identifyInputsAndOutputs) of the main model within a compilation. A fully specified tensor operand type must either be provided to ANeuralNetworksModel_addOperand; or it must be provided to the corresponding ANeuralNetworksExecution_setInput, or ANeuralNetworksExecution_setInputFromMemory. EXCEPTION: If the input is optional and omitted (by passing nullptr for buffer to ANeuralNetworksExecution_setInput) then it need not have a fully specified tensor operand type.
- The operand is a model output (see ANeuralNetworksModel_identifyInputsAndOutputs) of the main model within a compilation and is to be used with ANeuralNetworksExecution_startComputeWithDependencies. A fully specified tensor operand type must either be provided to ANeuralNetworksModel_addOperand; or it must be provided to the corresponding ANeuralNetworksExecution_setOutput, or ANeuralNetworksExecution_setOutputFromMemory.
A tensor operand type of specified rank but some number of unspecified dimensions is represented by setting dimensionCount to the rank and each unspecified dimension to 0.
Available since NNAPI feature level 1.
Starting at NNAPI feature level 3, a tensor operand type of unspecified rank is represented by setting dimensionCount to 0 and dimensions to NULL (just as if it were a scalar operand type).
Public attributes |
|
---|---|
dimensionCount
|
uint32_t
The number of dimensions (rank).
|
dimensions
|
const uint32_t *
The dimensions of the tensor.
|
scale
|
float
The quantization scale.
|
type
|
int32_t
The data type, e.g ANEURALNETWORKS_FLOAT32.
|
zeroPoint
|
int32_t
The quantization zero point.
|
Public attributes
dimensionCount
uint32_t ANeuralNetworksOperandType::dimensionCount
The number of dimensions (rank).
Must be 0 for scalars.
dimensions
const uint32_t * ANeuralNetworksOperandType::dimensions
The dimensions of the tensor.
Must be nullptr for scalars.
scale
float ANeuralNetworksOperandType::scale
type
int32_t ANeuralNetworksOperandType::type
The data type, e.g ANEURALNETWORKS_FLOAT32.
zeroPoint
int32_t ANeuralNetworksOperandType::zeroPoint