Stay organized with collections
Save and categorize content based on your preferences.
ANeuralNetworksOperandType
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:
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
Declared in android/NeuralNetworksTypes.h
uint32_t ANeuralNetworksOperandType::dimensionCount
The number of dimensions (rank).
Must be 0 for scalars.
dimensions
Declared in android/NeuralNetworksTypes.h
const uint32_t * ANeuralNetworksOperandType::dimensions
The dimensions of the tensor.
Must be nullptr for scalars.
scale
Declared in android/NeuralNetworksTypes.h
float ANeuralNetworksOperandType::scale
The quantization scale.
Must be 0 when not applicable to an operand type.
See OperandCode.
type
Declared in android/NeuralNetworksTypes.h
int32_t ANeuralNetworksOperandType::type
The data type, e.g ANEURALNETWORKS_FLOAT32.
zeroPoint
Declared in android/NeuralNetworksTypes.h
int32_t ANeuralNetworksOperandType::zeroPoint
The quantization zero point.
Must be 0 when not applicable to an operand type.
See OperandCode.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-01-15 UTC.
[null,null,["Last updated 2025-01-15 UTC."],[],[],null,["# ANeuralNetworksOperandType Struct Reference\n\nANeuralNetworksOperandType\n==========================\n\n[ANeuralNetworksOperandType](/ndk/reference/struct/a-neural-networks-operand-type#struct_a_neural_networks_operand_type) describes the type of an operand.\n\nSummary\n-------\n\nThis structure is used to describe both scalars and tensors.\n\nA tensor operand type with all dimensions specified is \"fully\nspecified\". 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.\n\nIf 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](/ndk/reference/group/neural-networks#group___neural_networks_1ggaabbe492c60331b13038e39d4207940e0ad9eb50679d1077710a6a4b3eb5207218) or [ANEURALNETWORKS_WHILE](/ndk/reference/group/neural-networks#group___neural_networks_1ggaabbe492c60331b13038e39d4207940e0afdc0927832c42f93845fd9a2361b35f9) operation input operand type in the case of referenced model input operands.\n\nIn the following situations, a tensor operand type must be fully specified:\n\n- The operand has a constant value, set by [ANeuralNetworksModel_setOperandValue](/ndk/reference/group/neural-networks#group___neural_networks_1ga92fd1d7bdf40364620d72fdaaca991f3) (with a non-nullptr buffer) or [ANeuralNetworksModel_setOperandValueFromMemory](/ndk/reference/group/neural-networks#group___neural_networks_1ga0a1bcce272ba5ddfaa3c06a53ac7a6ec).\n- The operand is a model input (see [ANeuralNetworksModel_identifyInputsAndOutputs](/ndk/reference/group/neural-networks#group___neural_networks_1gacef56268ac6e5e80fa0b4714f57772ce)) of the main model within a compilation. A fully specified tensor operand type must either be provided to [ANeuralNetworksModel_addOperand](/ndk/reference/group/neural-networks#group___neural_networks_1gabe3ab450ff498af8b3b4b88d5e256a36); or it must be provided to the corresponding [ANeuralNetworksExecution_setInput](/ndk/reference/group/neural-networks#group___neural_networks_1gac67f2c8f1ea2136d57bc871da2e6982f), or [ANeuralNetworksExecution_setInputFromMemory](/ndk/reference/group/neural-networks#group___neural_networks_1ga33a63f2ee1b1b17304f76ef8376af224). EXCEPTION: If the input is optional and omitted (by passing nullptr for buffer to [ANeuralNetworksExecution_setInput](/ndk/reference/group/neural-networks#group___neural_networks_1gac67f2c8f1ea2136d57bc871da2e6982f)) then it need not have a fully specified tensor operand type.\n- The operand is a model output (see [ANeuralNetworksModel_identifyInputsAndOutputs](/ndk/reference/group/neural-networks#group___neural_networks_1gacef56268ac6e5e80fa0b4714f57772ce)) of the main model within a compilation and is to be used with [ANeuralNetworksExecution_startComputeWithDependencies](/ndk/reference/group/neural-networks#group___neural_networks_1ga371f25c6c44c05f8d267bb6f27ceeb3a). A fully specified tensor operand type must either be provided to [ANeuralNetworksModel_addOperand](/ndk/reference/group/neural-networks#group___neural_networks_1gabe3ab450ff498af8b3b4b88d5e256a36); or it must be provided to the corresponding [ANeuralNetworksExecution_setOutput](/ndk/reference/group/neural-networks#group___neural_networks_1ga7c25ad87c553d207efb257d09e62801e), or [ANeuralNetworksExecution_setOutputFromMemory](/ndk/reference/group/neural-networks#group___neural_networks_1gafcd74c997781e196e081f19108e2c441).\n\n\u003cbr /\u003e\n\nA 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.\n\nAvailable since NNAPI feature level 1.\n\nStarting 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).\n\n| ### Public attributes ||\n|---------------------------------------------------------------------------------------------|-------------------------------------------------------|\n| [dimensionCount](#struct_a_neural_networks_operand_type_1a8e9b0f8229777661e6005b9d1847f026) | `uint32_t` The number of dimensions (rank). |\n| [dimensions](#struct_a_neural_networks_operand_type_1a6d70bf7a7ea5d2e61e674cf7b3393548) | `const uint32_t *` The dimensions of the tensor. |\n| [scale](#struct_a_neural_networks_operand_type_1aee95637670d7b7179b28a9d5a22f621a) | `float` The quantization scale. |\n| [type](#struct_a_neural_networks_operand_type_1aebe0bf8514de064d1d68e8857a3dccfd) | `int32_t` The data type, e.g ANEURALNETWORKS_FLOAT32. |\n| [zeroPoint](#struct_a_neural_networks_operand_type_1ad7e11ae6e4a5c0e338cfe5c9a1e9dbe8) | `int32_t` The quantization zero point. |\n\nPublic attributes\n-----------------\n\n### dimensionCount\n\nDeclared in `android/NeuralNetworksTypes.h` \n\n```scdoc\nuint32_t ANeuralNetworksOperandType::dimensionCount\n``` \nThe number of dimensions (rank).\n\nMust be 0 for scalars. \n\n### dimensions\n\nDeclared in `android/NeuralNetworksTypes.h` \n\n```gdscript\nconst uint32_t * ANeuralNetworksOperandType::dimensions\n``` \nThe dimensions of the tensor.\n\nMust be nullptr for scalars. \n\n### scale\n\nDeclared in `android/NeuralNetworksTypes.h` \n\n```text\nfloat ANeuralNetworksOperandType::scale\n``` \nThe quantization scale.\n\nMust be 0 when not applicable to an operand type.\n\nSee [OperandCode](/ndk/reference/group/neural-networks#group___neural_networks_1gaf06d1affd33f3bc698d0c04eceb23298). \n\n### type\n\nDeclared in `android/NeuralNetworksTypes.h` \n\n```carbon\nint32_t ANeuralNetworksOperandType::type\n``` \nThe data type, e.g ANEURALNETWORKS_FLOAT32. \n\n### zeroPoint\n\nDeclared in `android/NeuralNetworksTypes.h` \n\n```scdoc\nint32_t ANeuralNetworksOperandType::zeroPoint\n``` \nThe quantization zero point.\n\nMust be 0 when not applicable to an operand type.\n\nSee [OperandCode](/ndk/reference/group/neural-networks#group___neural_networks_1gaf06d1affd33f3bc698d0c04eceb23298)."]]