ANeuralNetworksOperandType

ANeuralNetworksOperandType describes the type of an operand. This structure is used to describe both scalars and tensors.

A tensor operand type must have a specified rank (number of dimensions) but may have any of its dimensions unspecified.

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.

<p>In the following situations, a tensor operand type must be fully specified:<ul> <li>The operand has a constant value, set by {@link ANeuralNetworksModel_setOperandValue} (with a non-nullptr buffer) or {@link ANeuralNetworksModel_setOperandValueFromMemory}.</li> <li>The operand is a model input or model output (see {@link ANeuralNetworksModel_identifyInputsAndOutputs}). A fully specified tensor operand type must either be provided to {@link ANeuralNetworksModel_addOperand}; or it must be provided to the corresponding {@link ANeuralNetworksExecution_setInput}, {@link ANeuralNetworksExecution_setInputFromMemory}, {@link ANeuralNetworksExecution_setOutput}, or {@link ANeuralNetworksModel_setOperandValueFromMemory}. EXCEPTION: If the input or output is optional and omitted (by passing nullptr for buffer to {@link ANeuralNetworksExecution_setInput} or {@link ANeuralNetworksExecution_setOutput}) then it need not have a fully specified tensor operand type.</li></ul>

A tensor operand type with some number of unspecified dimensions is represented by setting each unspecified dimension to 0.

Available since API level 27.

version(Android)
extern (C) @system nothrow @nogc
struct ANeuralNetworksOperandType {}

Members

Variables

dimensionCount
uint dimensionCount;

The number of dimensions (rank). It should be 0 for scalars.

dimensions
const(uint)* dimensions;

The dimensions of the tensor. It should be nullptr for scalars.

scale
float scale;

These two fields are only used for quantized tensors. They should be zero for scalars and non-fixed point tensors. The dequantized value of each entry is (value - zeroPoint) * scale.

type
int type;

The data type, e.g ANEURALNETWORKS_INT8.

zeroPoint
int zeroPoint;
Undocumented in source.

Meta