mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Replace sync_enums_to_hal.py with generate_api.{py,sh} and regenerate */types.hal
There are certain pieces of NeuralNetworks.h and of our various *.hal
files that ought to be kept in sync -- most notably the operand type
and operation type definitions and descriptions in our
NeuralNetworks.h and types.hal files. To avoid having to do this
manually, a tool can be employed.
The old solution to this problem is sync_enums_to_hal.py, which parses
the existing NeuralNetworks.h and types.hal files, and then rewrites
the types.hal files: It identifies the operand type and operation type
portions of the files, and in the types.hal files replaces them with
transformed versions of the portions from NeuralNetworks.h. This
approach is brittle -- it is very sensitive to the structure of the
files, as was recognized when this tool was created. Changes to those
files since the script was last updated essentially broke the script,
as noted in http://b/140132458.
The new solution employs a new tool generate_api.py to combine a
single "specification file" with one "template file" per API file
(NeuralNetworks.h or types.hal) to produce that API file. The script
generate_api.sh invokes generate_api.py once per API file, passing
appropriate arguments. See frameworks/ml/nn/tools/api/README.md for
more details.
In the process of combining information from NeuralNetworks.h and
*/types.hal, some formatting, syntactic, and semantic changes have
been made to those files. For example:
- types.hal files no longer refer to API levels or (similarly)
to HAL versions other than earlier HAL versions
Bug: 130169064
Bug: 140132458
Test: cd neuralnetworks ; mma
Change-Id: Iceb38effc2c7e6c32344e49225b85256144c0945
Merged-In: Iceb38effc2c7e6c32344e49225b85256144c0945
(cherry picked from commit 2cae5c8b01)
This commit is contained in:
@@ -574,8 +574,11 @@ cfa81f229b69f9011c58f48264fcb552447430fe68610eac514e811e65bc306a android.hardwar
|
||||
# ABI preserving changes to HALs during Android R
|
||||
b69a7615c508acf5c5201efd1bfa3262167874fc3594e2db5a3ff93addd8ac75 android.hardware.keymaster@4.0::IKeymasterDevice
|
||||
eb2fa0c883c2185d514be0b84c179b283753ef0c1b77b45b4f359bd23bba8b75 android.hardware.neuralnetworks@1.0::IPreparedModel
|
||||
f1109cbb10297b7429a11fab42afa912710b303c9bf20bd5cdb8bd57b9c84186 android.hardware.neuralnetworks@1.0::types
|
||||
9d8ee57c490ffeaa28f702eaea8d198cb510e4bbfb99e6cb5f63e73341057c7c android.hardware.neuralnetworks@1.1::types
|
||||
fb382e986c10b8fbb797a8546e8f9ea6d1107bfe6f3fb7e57f6bbbf1f807a906 android.hardware.neuralnetworks@1.2::IDevice
|
||||
40e71cd693de5b832325c5d8f081f2ff20a7ba2b89d401cee5b4b3eb0e241681 android.hardware.neuralnetworks@1.2::IPreparedModel
|
||||
71c0f7127335e5b74d1615d5e7f129831b43ffbae5318ad0924d7d8d8910a859 android.hardware.neuralnetworks@1.2::types
|
||||
a785a57447a81e9c130eef6904c3a5c256076c6a04588c40620ebd6fa2660d77 android.hardware.radio@1.2::types
|
||||
1a6e2bd289f22931c526b21916910f1d4c436b7acb9556e4243de4ce8e6cc2e4 android.hardware.soundtrigger@2.0::ISoundTriggerHwCallback
|
||||
fd65298e1e09e0e3c781ab18305920d757dbe55a3b459ce17814ec5cf6dfee99 android.hardware.wifi@1.0::IWifiP2pIface
|
||||
|
||||
@@ -25,25 +25,24 @@ package android.hardware.neuralnetworks@1.0;
|
||||
* with at least one dimension). Types not prefaced by TENSOR_* represent
|
||||
* scalar values and must have no dimensions.
|
||||
*
|
||||
* Although many types are defined, most operators accept just a few
|
||||
* Although we define many types, most operators accept just a few
|
||||
* types. Most used are {@link OperandType::TENSOR_FLOAT32},
|
||||
* {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* and {@link OperandType::INT32}.
|
||||
*/
|
||||
enum OperandType : int32_t {
|
||||
/** A 32 bit floating point scalar value. */
|
||||
FLOAT32 = 0,
|
||||
FLOAT32 = 0,
|
||||
/** A signed 32 bit integer scalar value. */
|
||||
INT32 = 1,
|
||||
INT32 = 1,
|
||||
/** An unsigned 32 bit integer scalar value. */
|
||||
UINT32 = 2,
|
||||
|
||||
UINT32 = 2,
|
||||
/** A tensor of 32 bit floating point values. */
|
||||
TENSOR_FLOAT32 = 3,
|
||||
TENSOR_FLOAT32 = 3,
|
||||
/** A tensor of 32 bit integer values. */
|
||||
TENSOR_INT32 = 4,
|
||||
TENSOR_INT32 = 4,
|
||||
/**
|
||||
* A tensor of 8 bit integers that represent real numbers.
|
||||
* 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:
|
||||
@@ -51,21 +50,21 @@ enum OperandType : int32_t {
|
||||
* - zeroPoint: a 32 bit integer, in range [0, 255].
|
||||
*
|
||||
* The formula is:
|
||||
* real_value = (integer_value - zeroPoint) * scale.
|
||||
* real_value = (integer_value - zeroPoint) * scale.
|
||||
*/
|
||||
TENSOR_QUANT8_ASYMM = 5,
|
||||
|
||||
/**
|
||||
* DEPRECATED. Since NNAPI 1.2, extensions are the preferred alternative to
|
||||
* OEM operation and data types.
|
||||
* DEPRECATED. Since HAL version 1.2, extensions are the preferred
|
||||
* alternative to OEM operation and data types.
|
||||
*
|
||||
* OEM specific scalar value.
|
||||
*/
|
||||
OEM = 10000,
|
||||
|
||||
/**
|
||||
* DEPRECATED. Since NNAPI 1.2, extensions are the preferred alternative to
|
||||
* OEM operation and data types.
|
||||
* DEPRECATED. Since HAL version 1.2, extensions are the preferred
|
||||
* alternative to OEM operation and data types.
|
||||
*
|
||||
* A tensor of OEM specific values.
|
||||
*/
|
||||
@@ -78,7 +77,6 @@ enum OperandType : int32_t {
|
||||
* The type of an operation in a model.
|
||||
*/
|
||||
enum OperationType : int32_t {
|
||||
|
||||
/**
|
||||
* Adds two tensors, element-wise.
|
||||
*
|
||||
@@ -110,14 +108,16 @@ enum OperationType : int32_t {
|
||||
* * 0: A tensor.
|
||||
* * 1: A tensor of the same {@link OperandType}, and compatible dimensions
|
||||
* as input0.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scales and zeroPoint can be different from input0 scale and zeroPoint.
|
||||
* * 2: An {@link OperandType::INT32} scalar, and has to be one of the
|
||||
* {@link FusedActivationFunc} values. Specifies the activation to
|
||||
* invoke on the result.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The sum, a tensor of the same {@link OperandType} as input0.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint can be different from inputs' scale and zeroPoint.
|
||||
*/
|
||||
ADD = 0,
|
||||
|
||||
@@ -187,8 +187,8 @@ enum OperationType : int32_t {
|
||||
* Outputs:
|
||||
* * 0: The output 4-D tensor, of shape
|
||||
* [batches, out_height, out_width, depth].
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
AVERAGE_POOL_2D = 1,
|
||||
|
||||
@@ -206,22 +206,23 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Inputs:
|
||||
* * 0 ~ n-1: The list of n input tensors, of shape
|
||||
* [D0, D1, ..., Daxis(i), ..., Dm]. For inputs of
|
||||
* {@link OperandType::TENSOR_QUANT8_ASYMM}, all input tensors
|
||||
* must have the same scale and zeroPoint.
|
||||
* [D0, D1, ..., Daxis(i), ..., Dm].
|
||||
* All input tensors of
|
||||
* {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
* must have the same scale and zeroPoint as the output tensor.
|
||||
* * n: An {@link OperandType::INT32} scalar, specifying the
|
||||
* concatenation axis.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output, a tensor of the same {@link OperandType} as the input
|
||||
* tensors. The output shape is [D0, D1, ..., sum(Daxis(i)), ..., Dm].
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor, the scale and zeroPoint
|
||||
* values must be the same as the input tensors'.
|
||||
*/
|
||||
CONCATENATION = 2,
|
||||
|
||||
/**
|
||||
* Performs an 2-D convolution operation.
|
||||
* 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
|
||||
@@ -238,11 +239,17 @@ enum OperationType : int32_t {
|
||||
* filter[channel, di, dj, k]
|
||||
* ) + bias[channel]
|
||||
*
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
* Supported tensor {@link OperandType} configurations:
|
||||
* * 32 bit floating point:
|
||||
* * * {@link OperandType::TENSOR_FLOAT32} for input, filter, output, and bias.
|
||||
*
|
||||
* Supported tensor rank: 4, with "NHWC" data layout.
|
||||
* * Quantized:
|
||||
* * * {@link OperandType::TENSOR_QUANT8_ASYMM} for input, filter, and output.
|
||||
* * * {@link OperandType::TENSOR_INT32} for bias (with scale set to
|
||||
* * * input.scale * filter.scale).
|
||||
*
|
||||
* Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width,
|
||||
* and Channels) data layout.
|
||||
*
|
||||
* Both explicit padding and implicit padding are supported.
|
||||
*
|
||||
@@ -252,12 +259,12 @@ enum OperationType : int32_t {
|
||||
* * 1: A 4-D tensor, of shape
|
||||
* [depth_out, filter_height, filter_width, depth_in], specifying the
|
||||
* filter.
|
||||
* * 2: A 1-D tensor, of shape [depth_out], specifying the bias.
|
||||
* For input tensor of {@link OperandType::TENSOR_FLOAT32}, the bias
|
||||
* should also be of {@link OperandType::TENSOR_FLOAT32}. For input
|
||||
* tensor of {@link OperandType::TENSOR_QUANT8_ASYMM}, the bias
|
||||
* should be of {@link OperandType::TENSOR_INT32}, with zeroPoint of
|
||||
* 0 and bias_scale == input_scale * filter_scale.
|
||||
* * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input
|
||||
* tensor of type {@link OperandType::TENSOR_FLOAT32}
|
||||
* the bias must be of the same
|
||||
* type. For filter tensor of {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* the bias should be of {@link OperandType::TENSOR_INT32}, with zeroPoint
|
||||
* of 0 and bias_scale == input_scale * filter_scale.
|
||||
* * 3: An {@link OperandType::INT32} scalar, specifying the padding on
|
||||
* the left, in the ‘width’ dimension.
|
||||
* * 4: An {@link OperandType::INT32} scalar, specifying the padding on
|
||||
@@ -281,11 +288,11 @@ enum OperationType : int32_t {
|
||||
* [depth_out, filter_height, filter_width, depth_in], specifying the
|
||||
* filter.
|
||||
* * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input
|
||||
* tensor of {@link OperandType::TENSOR_FLOAT32}, the bias should
|
||||
* also be of {@link OperandType::TENSOR_FLOAT32}. For input tensor
|
||||
* of {@link OperandType::TENSOR_QUANT8_ASYMM}, the bias should be
|
||||
* of {@link OperandType::TENSOR_INT32}, with zeroPoint of 0 and
|
||||
* bias_scale == input_scale * filter_scale.
|
||||
* tensor of type {@link OperandType::TENSOR_FLOAT32}
|
||||
* the bias must be of the same
|
||||
* type. For filter tensor of {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* the bias should be of {@link OperandType::TENSOR_INT32}, with zeroPoint
|
||||
* of 0 and bias_scale == input_scale * filter_scale.
|
||||
* * 3: An {@link OperandType::INT32} scalar, specifying the implicit
|
||||
* padding scheme, has to be one of the
|
||||
* following values: {0 (NONE), 1 (SAME), 2 (VALID)}.
|
||||
@@ -299,11 +306,9 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output 4-D tensor, of shape
|
||||
* [batches, out_height, out_width, depth_out]. For output tensor of
|
||||
* {@link OperandType::TENSOR_QUANT8_ASYMM}, the following condition
|
||||
* must be satisfied: output_scale > input_scale * filter_scale.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* [batches, out_height, out_width, depth_out].
|
||||
* For output tensor of {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* the following condition must be satisfied: output_scale > input_scale * filter_scale
|
||||
*/
|
||||
CONV_2D = 3,
|
||||
|
||||
@@ -329,11 +334,17 @@ enum OperationType : int32_t {
|
||||
* filter[1, di, dj, k * channel_multiplier + q]
|
||||
* ) + bias[k * channel_multiplier + q]
|
||||
*
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
* Supported tensor {@link OperandType} configurations:
|
||||
* * 32 bit floating point:
|
||||
* * * {@link OperandType::TENSOR_FLOAT32} for input, filter, output, and bias.
|
||||
*
|
||||
* Supported tensor rank: 4, with "NHWC" data layout.
|
||||
* * Quantized:
|
||||
* * * {@link OperandType::TENSOR_QUANT8_ASYMM} for input, filter, and output.
|
||||
* * * {@link OperandType::TENSOR_INT32} for bias (with scale set to
|
||||
* * * input.scale * filter.scale).
|
||||
*
|
||||
* Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width,
|
||||
* and Channels) data layout.
|
||||
*
|
||||
* Both explicit padding and implicit padding are supported.
|
||||
*
|
||||
@@ -343,11 +354,11 @@ enum OperationType : int32_t {
|
||||
* * 1: A 4-D tensor, of shape [1, filter_height, filter_width, depth_out],
|
||||
* specifying the filter.
|
||||
* * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input
|
||||
* tensor of {@link OperandType::TENSOR_FLOAT32}, the bias should
|
||||
* also be of {@link OperandType::TENSOR_FLOAT32}. For input tensor
|
||||
* of {@link OperandType::TENSOR_QUANT8_ASYMM}, the bias should be
|
||||
* of {@link OperandType::TENSOR_INT32}, with zeroPoint of 0 and
|
||||
* bias_scale == input_scale * filter_scale.
|
||||
* tensor of type {@link OperandType::TENSOR_FLOAT32}
|
||||
* the bias must be of the same
|
||||
* type. For filter tensor of {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* the bias should be of {@link OperandType::TENSOR_INT32}, with zeroPoint
|
||||
* of 0 and bias_scale == input_scale * filter_scale.
|
||||
* * 3: An {@link OperandType::INT32} scalar, specifying the padding on
|
||||
* the left, in the ‘width’ dimension.
|
||||
* * 4: An {@link OperandType::INT32} scalar, specifying the padding on
|
||||
@@ -372,11 +383,11 @@ enum OperationType : int32_t {
|
||||
* * 1: A 4-D tensor, of shape [1, filter_height, filter_width, depth_out],
|
||||
* specifying the filter.
|
||||
* * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input
|
||||
* tensor of {@link OperandType::TENSOR_FLOAT32}, the bias should
|
||||
* also be of {@link OperandType::TENSOR_FLOAT32}. For input tensor
|
||||
* of {@link OperandType::TENSOR_QUANT8_ASYMM}, the bias should be
|
||||
* of {@link OperandType::TENSOR_INT32}, with zeroPoint of 0 and
|
||||
* bias_scale == input_scale * filter_scale.
|
||||
* tensor of type {@link OperandType::TENSOR_FLOAT32}
|
||||
* the bias must be of the same
|
||||
* type. For filter tensor of {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* the bias should be of {@link OperandType::TENSOR_INT32}, with zeroPoint
|
||||
* of 0 and bias_scale == input_scale * filter_scale.
|
||||
* * 3: An {@link OperandType::INT32} scalar, specifying the implicit
|
||||
* padding scheme, has to be one of the
|
||||
* following values: {0 (NONE), 1 (SAME), 2 (VALID)}.
|
||||
@@ -392,11 +403,10 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output 4-D tensor, of shape
|
||||
* [batches, out_height, out_width, depth_out]. For output tensor of
|
||||
* {@link OperandType::TENSOR_QUANT8_ASYMM}, the following condition
|
||||
* must be satisfied: output_scale > input_scale * filter_scale.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* [batches, out_height, out_width, depth_out]. For
|
||||
* output tensor of {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* the following condition must be satisfied:
|
||||
* output_scale > input_scale * filter_scale
|
||||
*/
|
||||
DEPTHWISE_CONV_2D = 4,
|
||||
|
||||
@@ -419,7 +429,8 @@ enum OperationType : int32_t {
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
*
|
||||
* Supported tensor rank: 4, with "NHWC" data layout.
|
||||
* Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width,
|
||||
* and Channels) data layout.
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: A 4-D tensor, of shape [batches, height, width, depth_in],
|
||||
@@ -431,8 +442,8 @@ enum OperationType : int32_t {
|
||||
* Outputs:
|
||||
* * 0: The output 4-D tensor, of shape [batch, height*block_size,
|
||||
* width*block_size, depth/(block_size*block_size)].
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
DEPTH_TO_SPACE = 5,
|
||||
|
||||
@@ -443,19 +454,19 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* output = (input - zeroPoint) * scale.
|
||||
*
|
||||
* Supported tensor {@link OperandType}:
|
||||
* Supported input tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
*
|
||||
* Supported output tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}.
|
||||
*
|
||||
* Supported tensor rank: up to 4
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: A tensor of {@link OperandType::TENSOR_QUANT8_ASYMM}.
|
||||
* * 0: A tensor.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor of same shape as input0, but with
|
||||
* {@link OperandType::TENSOR_FLOAT32}.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* * 0: A tensor with the same shape as input0.
|
||||
*/
|
||||
DEQUANTIZE = 6,
|
||||
|
||||
@@ -479,6 +490,13 @@ enum OperationType : int32_t {
|
||||
* If a value in Lookups is out of bounds, the operation must fail
|
||||
* and an error must be reported.
|
||||
*
|
||||
* Supported value tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_INT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
*
|
||||
* Supported value tensor rank: from 2
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: Lookups. A 1-D tensor of {@link OperandType::TENSOR_INT32}.
|
||||
* The values are indices into the first dimension of Values.
|
||||
@@ -489,8 +507,8 @@ enum OperationType : int32_t {
|
||||
* * 0: A n-D tensor with the same rank and shape as the Values
|
||||
* tensor, except for the first dimension which has the same size
|
||||
* as Lookups' only dimension.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input1.
|
||||
*/
|
||||
EMBEDDING_LOOKUP = 7,
|
||||
|
||||
@@ -508,8 +526,6 @@ enum OperationType : int32_t {
|
||||
* Outputs:
|
||||
* * 0: The output tensor, of the same {@link OperandType} and dimensions as
|
||||
* the input tensor.
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
FLOOR = 8,
|
||||
|
||||
@@ -549,12 +565,9 @@ enum OperationType : int32_t {
|
||||
* invoke on the result.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor, of shape [batch_size, num_units]. For output
|
||||
* tensor of {@link OperandType::TENSOR_QUANT8_ASYMM}, the following
|
||||
* condition must be satisfied:
|
||||
* output_scale > input_scale * filter_scale.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* * 0: The output tensor, of shape [batch_size, num_units]. For
|
||||
* output tensor of {@link OperandType::TENSOR_QUANT8_ASYMM}, the following
|
||||
* condition must be satisfied: output_scale > input_scale * filter_scale.
|
||||
*/
|
||||
FULLY_CONNECTED = 9,
|
||||
|
||||
@@ -585,6 +598,13 @@ enum OperationType : int32_t {
|
||||
* must be selected. If no entry in Keys has 123456, a slice of zeroes
|
||||
* must be concatenated.
|
||||
*
|
||||
* Supported value tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_INT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
*
|
||||
* Supported value tensor rank: from 2
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: Lookups. A 1-D {@link OperandType::TENSOR_INT32} tensor with
|
||||
* shape [ k ].
|
||||
@@ -598,13 +618,13 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: Output. A tensor with shape [ k …].
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input2.
|
||||
* * 1: Hits. A boolean tensor with shape [ k ] indicates whether the lookup
|
||||
* hits (True) or not (False).
|
||||
* Stored as {@link OperandType::TENSOR_QUANT8_ASYMM} with offset 0
|
||||
* and scale 1.0f.
|
||||
* A non-zero byte represents True, a hit. A zero indicates otherwise.
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
HASHTABLE_LOOKUP = 10,
|
||||
|
||||
@@ -617,9 +637,6 @@ enum OperationType : int32_t {
|
||||
* input[batch, row, col, channel] /
|
||||
* sqrt(sum_{c} pow(input[batch, row, col, c], 2))
|
||||
*
|
||||
* For input tensor with more dimensions, independently normalizes each 1-D
|
||||
* slice along dimension dim.
|
||||
*
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
*
|
||||
@@ -627,13 +644,10 @@ enum OperationType : int32_t {
|
||||
* Height, Width, and Channels).
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: A 4-D tensor, of shape [batches, height, width, depth].
|
||||
* * 0: A 4-D tensor, specifying the tensor to be normalized.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output 4-D tensor, of the same shape as input
|
||||
* [batches, height, width, depth].
|
||||
*
|
||||
* Available since API level 27.
|
||||
* * 0: A tensor of the same {@link OperandType} and same shape as input0.
|
||||
*/
|
||||
L2_NORMALIZATION = 11,
|
||||
|
||||
@@ -652,7 +666,8 @@ enum OperationType : int32_t {
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
*
|
||||
* Supported tensor rank: 4, with "NHWC" data layout.
|
||||
* Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width,
|
||||
* and Channels) data layout.
|
||||
*
|
||||
* Both explicit padding and implicit padding are supported.
|
||||
*
|
||||
@@ -700,8 +715,6 @@ enum OperationType : int32_t {
|
||||
* Outputs:
|
||||
* * 0: The output 4-D tensor, of shape
|
||||
* [batches, out_height, out_width, depth].
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
L2_POOL_2D = 12,
|
||||
|
||||
@@ -729,17 +742,18 @@ enum OperationType : int32_t {
|
||||
* the input.
|
||||
* * 1: An {@link OperandType::INT32} scalar, specifying the radius of
|
||||
* the normalization window.
|
||||
* * 2: An {@link OperandType::FLOAT32} scalar, specifying the bias, must
|
||||
* not be zero.
|
||||
* * 3: An {@link OperandType::FLOAT32} scalar, specifying the scale
|
||||
* factor, alpha.
|
||||
* * 4: An {@link OperandType::FLOAT32} scalar, specifying the exponent,
|
||||
* beta.
|
||||
* * 2: A scalar, specifying the bias, must not be zero.
|
||||
* For input tensor of {@link OperandType::TENSOR_FLOAT32}, the bias
|
||||
* value must be of {@link OperandType::FLOAT32}.
|
||||
* * 3: A scalar, specifying the scale factor, alpha.
|
||||
* For input tensor of {@link OperandType::TENSOR_FLOAT32}, the
|
||||
* alpha value must be of {@link OperandType::FLOAT32}.
|
||||
* * 4: A scalar, specifying the exponent, beta.
|
||||
* For input tensor of {@link OperandType::TENSOR_FLOAT32}, the beta
|
||||
* value must be of {@link OperandType::FLOAT32}.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor of same shape as input0.
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
LOCAL_RESPONSE_NORMALIZATION = 13,
|
||||
|
||||
@@ -763,45 +777,53 @@ enum OperationType : int32_t {
|
||||
* * 0: The output tensor of same shape as input0.
|
||||
* For {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* the scale must be 1.f / 256 and the zeroPoint must be 0.
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
LOGISTIC = 14,
|
||||
|
||||
/**
|
||||
* Projects an input to a bit vector via locality senstive hashing.
|
||||
*
|
||||
* Supported input tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_INT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
*
|
||||
* Supported input tensor rank: from 1
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: Hash functions. Dim.size == 2, DataType: Float.
|
||||
* Tensor[0].Dim[0]: Number of hash functions.
|
||||
* Tensor[0].Dim[1]: Number of seeds per hash functions.
|
||||
* Tensor[0].Dim[1] <= 32 in sparse case.
|
||||
* Tensor[0].Dim[0]: Number of hash functions.
|
||||
* Tensor[0].Dim[1]: Number of projected output bits generated by each
|
||||
* hash function.
|
||||
* If the projection type is Sparse:
|
||||
* Tensor[0].Dim[1] + ceil(log2(Tensor[0].Dim[0])) <= 32
|
||||
*
|
||||
* * 1: Input. Dim.size >= 1, no restriction on DataType.
|
||||
* * 2: Weight. Optional. Dim.size == 1, DataType: Float.
|
||||
* If not set, each input element is considered to have the same weight
|
||||
* of 1.0.
|
||||
* Tensor[1].Dim[0] == Tensor[2].Dim[0]
|
||||
* If not set, each input element is considered to have the same weight
|
||||
* of 1.0.
|
||||
* Tensor[1].Dim[0] == Tensor[2].Dim[0]
|
||||
* * 3: Type:
|
||||
* Sparse: Value LSHProjectionType_SPARSE(=1).
|
||||
* Sparse:
|
||||
* Value LSHProjectionType_SPARSE(=1).
|
||||
* Computed bit vector is considered to be sparse.
|
||||
* Each output element is an int32 made up of multiple bits
|
||||
* computed from hash functions.
|
||||
*
|
||||
* Dense: Value LSHProjectionType_DENSE(=2).
|
||||
* Dense:
|
||||
* Value LSHProjectionType_DENSE(=2).
|
||||
* Computed bit vector is considered to be dense. Each output
|
||||
* element represents a bit and can take the value of either
|
||||
* 0 or 1.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: If the projection type is sparse:
|
||||
* Output.Dim == { Tensor[0].Dim[0] }
|
||||
* A tensor of int32 that represents hash signatures.
|
||||
* If the projection type is Dense:
|
||||
* Output.Dim == { Tensor[0].Dim[0] * Tensor[0].Dim[1] }
|
||||
* A flattened tensor that represents projected bit vectors.
|
||||
* * 0: If the projection type is Sparse:
|
||||
* Output.Dim == { Tensor[0].Dim[0] }
|
||||
* A tensor of int32 that represents hash signatures.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* If the projection type is Dense:
|
||||
* Output.Dim == { Tensor[0].Dim[0] * Tensor[0].Dim[1] }
|
||||
* A flattened tensor that represents projected bit vectors.
|
||||
*/
|
||||
LSH_PROJECTION = 15,
|
||||
|
||||
@@ -901,71 +923,54 @@ enum OperationType : int32_t {
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
*
|
||||
* All input and output tensors must be of the same type.
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: The input (\f$x_t\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, input_size], where “batch_size” corresponds to the
|
||||
* batching dimension, and “input_size” is the size of the input.
|
||||
* A 2-D tensor of shape [batch_size, input_size], where “batch_size”
|
||||
* corresponds to the batching dimension, and “input_size” is the size
|
||||
* of the input.
|
||||
* * 1: The input-to-input weights (\f$W_{xi}\f$). Optional.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, input_size], where “num_units” corresponds to the
|
||||
* number of cell units.
|
||||
* A 2-D tensor of shape [num_units, input_size], where “num_units”
|
||||
* corresponds to the number of cell units.
|
||||
* * 2: The input-to-forget weights (\f$W_{xf}\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, input_size].
|
||||
* A 2-D tensor of shape [num_units, input_size].
|
||||
* * 3: The input-to-cell weights (\f$W_{xc}\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, input_size].
|
||||
* A 2-D tensor of shape [num_units, input_size].
|
||||
* * 4: The input-to-output weights (\f$W_{xo}\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, input_size].
|
||||
* A 2-D tensor of shape [num_units, input_size].
|
||||
* * 5: The recurrent-to-input weights (\f$W_{hi}\f$). Optional.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, output_size], where “output_size” corresponds to either
|
||||
* the number of cell units (i.e., “num_units”), or the second
|
||||
* dimension of the “projection_weights”, if defined.
|
||||
* A 2-D tensor of shape [num_units, output_size], where “output_size”
|
||||
* corresponds to either the number of cell units (i.e., “num_units”),
|
||||
* or the second dimension of the “projection_weights”, if defined.
|
||||
* * 6: The recurrent-to-forget weights (\f$W_{hf}\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, output_size].
|
||||
* A 2-D tensor of shape [num_units, output_size].
|
||||
* * 7: The recurrent-to-cell weights (\f$W_{hc}\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, output_size].
|
||||
* A 2-D tensor of shape [num_units, output_size].
|
||||
* * 8: The recurrent-to-output weights (\f$W_{ho}\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, output_size].
|
||||
* A 2-D tensor of shape [num_units, output_size].
|
||||
* * 9: The cell-to-input weights (\f$W_{ci}\f$). Optional.
|
||||
* A 1-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units].
|
||||
* A 1-D tensor of shape [num_units].
|
||||
* * 10:The cell-to-forget weights (\f$W_{cf}\f$). Optional.
|
||||
* A 1-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units].
|
||||
* A 1-D tensor of shape [num_units].
|
||||
* * 11:The cell-to-output weights (\f$W_{co}\f$). Optional.
|
||||
* A 1-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units].
|
||||
* A 1-D tensor of shape [num_units].
|
||||
* * 12:The input gate bias (\f$b_i\f$). Optional.
|
||||
* A 1-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units].
|
||||
* A 1-D tensor of shape [num_units].
|
||||
* * 13:The forget gate bias (\f$b_f\f$).
|
||||
* A 1-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units].
|
||||
* A 1-D tensor of shape [num_units].
|
||||
* * 14:The cell bias (\f$b_c\f$).
|
||||
* A 1-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units].
|
||||
* A 1-D tensor of shape [num_units].
|
||||
* * 15:The output gate bias (\f$b_o\f$).
|
||||
* A 1-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units].
|
||||
* A 1-D tensor of shape [num_units].
|
||||
* * 16:The projection weights (\f$W_{proj}\f$). Optional.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [output_size, num_units].
|
||||
* A 2-D tensor of shape [output_size, num_units].
|
||||
* * 17:The projection bias (\f$b_{proj}\f$). Optional.
|
||||
* A 1-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [output_size].
|
||||
* A 1-D tensor of shape [output_size].
|
||||
* * 18:The output state (in) (\f$h_{t-1}\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, output_size].
|
||||
* A 2-D tensor of shape [batch_size, output_size].
|
||||
* * 19:The cell state (in) (\f$C_{t-1}\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, num_units].
|
||||
* A 2-D tensor of shape [batch_size, num_units].
|
||||
* * 20:The activation function (\f$g\f$).
|
||||
* A value indicating the activation function:
|
||||
* <ul>
|
||||
@@ -984,21 +989,15 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The scratch buffer.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, num_units * 3] with CIFG, or
|
||||
* A 2-D tensor of shape [batch_size, num_units * 3] with CIFG, or
|
||||
* [batch_size, num_units * 4] without CIFG.
|
||||
* * 1: The output state (out) (\f$h_t\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, output_size].
|
||||
* A 2-D tensor of shape [batch_size, output_size].
|
||||
* * 2: The cell state (out) (\f$C_t\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, num_units].
|
||||
* A 2-D tensor of shape [batch_size, num_units].
|
||||
* * 3: The output (\f$o_t\f$).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, output_size]. This is effectively the same as the
|
||||
* current “output state (out)” value.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* A 2-D tensor of shape [batch_size, output_size]. This is effectively
|
||||
* the same as the current “output state (out)” value.
|
||||
*/
|
||||
LSTM = 16,
|
||||
|
||||
@@ -1019,7 +1018,8 @@ enum OperationType : int32_t {
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
*
|
||||
* Supported tensor rank: 4, with "NHWC" data layout.
|
||||
* Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width,
|
||||
* and Channels) data layout.
|
||||
*
|
||||
* Both explicit padding and implicit padding are supported.
|
||||
*
|
||||
@@ -1067,8 +1067,8 @@ enum OperationType : int32_t {
|
||||
* Outputs:
|
||||
* * 0: The output 4-D tensor, of shape
|
||||
* [batches, out_height, out_width, depth].
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
MAX_POOL_2D = 17,
|
||||
|
||||
@@ -1106,8 +1106,6 @@ enum OperationType : int32_t {
|
||||
* For output tensor of {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* the following condition must be satisfied:
|
||||
* output_scale > input1_scale * input2_scale.
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
MUL = 18,
|
||||
|
||||
@@ -1129,8 +1127,8 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor of same shape as input0.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
RELU = 19,
|
||||
|
||||
@@ -1151,9 +1149,9 @@ enum OperationType : int32_t {
|
||||
* * 0: A tensor, specifying the input.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor of same shape as input0.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* * 0: The output tensor of the same shape as input0.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
RELU1 = 20,
|
||||
|
||||
@@ -1175,8 +1173,8 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor of same shape as input0.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
RELU6 = 21,
|
||||
|
||||
@@ -1205,8 +1203,8 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor, of shape specified by the input shape.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
RESHAPE = 22,
|
||||
|
||||
@@ -1220,9 +1218,10 @@ enum OperationType : int32_t {
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
*
|
||||
* Supported tensor rank: 4, with "NHWC" data layout.
|
||||
* Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width,
|
||||
* and Channels) data layout.
|
||||
*
|
||||
* Inputs:
|
||||
* Inputs (resizing by shape):
|
||||
* * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying
|
||||
* the input.
|
||||
* * 1: An {@link OperandType::INT32} scalar, specifying the output
|
||||
@@ -1233,8 +1232,6 @@ enum OperationType : int32_t {
|
||||
* Outputs:
|
||||
* * 0: The output 4-D tensor, of shape
|
||||
* [batches, new_height, new_width, depth].
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
RESIZE_BILINEAR = 23,
|
||||
|
||||
@@ -1257,25 +1254,23 @@ enum OperationType : int32_t {
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
*
|
||||
* The input tensors must all be the same type.
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: input.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32} of shape
|
||||
* [batch_size, input_size], where “batch_size” corresponds to the
|
||||
* batching dimension, and “input_size” is the size of the input.
|
||||
* A 2-D tensor of shape [batch_size, input_size], where “batch_size”
|
||||
* corresponds to the batching dimension, and “input_size” is the size
|
||||
* of the input.
|
||||
* * 1: weights.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, input_size], where “num_units” corresponds to the
|
||||
* number of units.
|
||||
* A 2-D tensor of shape [num_units, input_size], where “num_units”
|
||||
* corresponds to the number of units.
|
||||
* * 2: recurrent_weights.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, num_units], with columns corresponding to the weights
|
||||
* from each unit.
|
||||
* A 2-D tensor of shape [num_units, num_units], with columns
|
||||
* corresponding to the weights from each unit.
|
||||
* * 3: bias.
|
||||
* A 1-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units].
|
||||
* A 1-D tensor of shape [num_units].
|
||||
* * 4: hidden state (in).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, num_units].
|
||||
* A 2-D tensor of shape [batch_size, num_units].
|
||||
* * 5: fused_activation_function.
|
||||
* An optional {@link FusedActivationFunc} value indicating the
|
||||
* activation function. If “NONE” is specified then it results in a
|
||||
@@ -1283,15 +1278,11 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: hidden state (out).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, num_units].
|
||||
* A 2-D tensor of shape [batch_size, num_units].
|
||||
*
|
||||
* * 1: output.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, num_units]. This is effectively the same as the
|
||||
* current state value.
|
||||
*
|
||||
* Available since API level 27.
|
||||
* A 2-D tensor of shape [batch_size, num_units]. This is effectively
|
||||
* the same as the current state value.
|
||||
*/
|
||||
RNN = 24,
|
||||
|
||||
@@ -1306,6 +1297,9 @@ enum OperationType : int32_t {
|
||||
* exp((input[batch, i] - max(input[batch, :])) * beta) /
|
||||
* sum_{k}{exp((input[batch, k] - max(input[batch, :])) * beta)}
|
||||
*
|
||||
* For input tensor with rank other than 2, the activation will be applied
|
||||
* independently on each 1-D slice along specified dimension.
|
||||
*
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
@@ -1314,15 +1308,15 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: A 2-D or 4-D tensor, specifying the tensor to be reshaped.
|
||||
* * 1: An {@link OperandType::FLOAT32} scalar, specifying the positive
|
||||
* scaling factor for the exponent, beta.
|
||||
* * 1: A scalar, specifying the positive scaling factor for the exponent,
|
||||
* beta. If input0 is of {@link OperandType::TENSOR_FLOAT32} or
|
||||
* {@link OperandType::TENSOR_QUANT8_ASYMM}, the scalar must be of
|
||||
* {@link OperandType::FLOAT32}.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor of same shape as input0.
|
||||
* For {@link OperandType::TENSOR_QUANT8_ASYMM},
|
||||
* the scale must be 1.f / 256 and the zeroPoint must be 0.
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
SOFTMAX = 25,
|
||||
|
||||
@@ -1344,7 +1338,8 @@ enum OperationType : int32_t {
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
*
|
||||
* Supported tensor rank: 4, with "NHWC" data layout.
|
||||
* Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width,
|
||||
* and Channels) data layout.
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: A 4-D tensor, of shape [batches, height, width, depth_in],
|
||||
@@ -1356,8 +1351,8 @@ enum OperationType : int32_t {
|
||||
* Outputs:
|
||||
* * 0: The output 4-D tensor, of shape [batches, height/block_size,
|
||||
* width/block_size, depth_in*block_size*block_size].
|
||||
*
|
||||
* Available since API level 27.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
SPACE_TO_DEPTH = 26,
|
||||
|
||||
@@ -1403,25 +1398,23 @@ enum OperationType : int32_t {
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
*
|
||||
* All input tensors must be the same type.
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: input.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, input_size], where “batch_size” corresponds to the
|
||||
* batching dimension, and “input_size” is the size of the input.
|
||||
* A 2-D tensor of shape [batch_size, input_size], where “batch_size”
|
||||
* corresponds to the batching dimension, and “input_size” is the size
|
||||
* of the input.
|
||||
* * 1: weights_feature.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, input_size], where “num_units” corresponds to the
|
||||
* number of units.
|
||||
* A 2-D tensor of shape [num_units, input_size], where “num_units”
|
||||
* corresponds to the number of units.
|
||||
* * 2: weights_time.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [num_units, memory_size], where “memory_size” corresponds to the
|
||||
* fixed-size of the memory.
|
||||
* A 2-D tensor of shape [num_units, memory_size], where “memory_size”
|
||||
* corresponds to the fixed-size of the memory.
|
||||
* * 3: bias.
|
||||
* An optional 1-D tensor of {@link OperandType::TENSOR_FLOAT32},
|
||||
* of shape [num_units].
|
||||
* An optional 1-D tensor of shape [num_units].
|
||||
* * 4: state (in).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* [batch_size, (memory_size - 1) * num_units * rank].
|
||||
* A 2-D tensor of shape [batch_size, (memory_size - 1) * num_units * rank].
|
||||
* * 5: rank.
|
||||
* The rank of the SVD approximation.
|
||||
* * 6: fused_activation_function.
|
||||
@@ -1431,13 +1424,11 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: state (out).
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* A 2-D tensor of the same {@link OperandType} as the inputs, with shape
|
||||
* [batch_size, (memory_size - 1) * num_units * rank].
|
||||
* * 1: output.
|
||||
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
|
||||
* A 2-D tensor of the same {@link OperandType} as the inputs, with shape
|
||||
* [batch_size, num_units].
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
SVDF = 27,
|
||||
|
||||
@@ -1458,8 +1449,6 @@ enum OperationType : int32_t {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor of same shape as input0.
|
||||
*
|
||||
* Available since API level 27.
|
||||
*/
|
||||
TANH = 28,
|
||||
|
||||
|
||||
431
neuralnetworks/1.0/types.t
Normal file
431
neuralnetworks/1.0/types.t
Normal file
@@ -0,0 +1,431 @@
|
||||
%% template file for generating types.hal.
|
||||
%% see frameworks/ml/nn/tools/api/README.md.
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.neuralnetworks@1.0;
|
||||
|
||||
%insert Operand_1.0_Comment
|
||||
enum OperandType : int32_t {
|
||||
%insert Operand_1.0
|
||||
|
||||
/**
|
||||
* DEPRECATED. Since HAL version 1.2, extensions are the preferred
|
||||
* alternative to OEM operation and data types.
|
||||
*
|
||||
* OEM specific scalar value.
|
||||
*/
|
||||
OEM = 10000,
|
||||
|
||||
/**
|
||||
* DEPRECATED. Since HAL version 1.2, extensions are the preferred
|
||||
* alternative to OEM operation and data types.
|
||||
*
|
||||
* A tensor of OEM specific values.
|
||||
*/
|
||||
TENSOR_OEM_BYTE = 10001,
|
||||
};
|
||||
|
||||
%insert Operation_1.0_Comment
|
||||
enum OperationType : int32_t {
|
||||
%insert Operation_1.0
|
||||
|
||||
/**
|
||||
* DEPRECATED. Since NNAPI 1.2, extensions are the preferred alternative to
|
||||
* OEM operation and data types.
|
||||
*
|
||||
* This operation is OEM specific. It should only be used for OEM
|
||||
* applications.
|
||||
*/
|
||||
OEM_OPERATION = 10000,
|
||||
};
|
||||
|
||||
/**
|
||||
* Fused activation function types.
|
||||
*/
|
||||
enum FusedActivationFunc : int32_t {
|
||||
NONE = 0,
|
||||
RELU = 1,
|
||||
RELU1 = 2,
|
||||
RELU6 = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* How an operand is used.
|
||||
*/
|
||||
enum OperandLifeTime : int32_t {
|
||||
/**
|
||||
* The operand is internal to the model. It's created by an operation and
|
||||
* consumed by other operations. It must be an output operand of
|
||||
* exactly one operation.
|
||||
*/
|
||||
TEMPORARY_VARIABLE,
|
||||
|
||||
/**
|
||||
* The operand is an input of the model. It must not be an output
|
||||
* operand of any operation.
|
||||
*
|
||||
* An operand can't be both input and output of a model.
|
||||
*/
|
||||
MODEL_INPUT,
|
||||
|
||||
/**
|
||||
* The operand is an output of the model. It must be an output
|
||||
* operand of exactly one operation.
|
||||
*
|
||||
* An operand can't be both input and output of a model.
|
||||
*/
|
||||
MODEL_OUTPUT,
|
||||
|
||||
/**
|
||||
* The operand is a constant found in Model.operandValues. It must
|
||||
* not be an output operand of any operation.
|
||||
*/
|
||||
CONSTANT_COPY,
|
||||
|
||||
/**
|
||||
* The operand is a constant that was specified via a Memory
|
||||
* object. It must not be an output operand of any operation.
|
||||
*/
|
||||
CONSTANT_REFERENCE,
|
||||
|
||||
/**
|
||||
* The operand does not have a value. This is valid only for optional
|
||||
* arguments of operations.
|
||||
*/
|
||||
NO_VALUE,
|
||||
};
|
||||
|
||||
/**
|
||||
* Status of a device.
|
||||
*/
|
||||
enum DeviceStatus : int32_t {
|
||||
AVAILABLE,
|
||||
BUSY,
|
||||
OFFLINE,
|
||||
UNKNOWN,
|
||||
};
|
||||
|
||||
/**
|
||||
* Performance information for the reference workload.
|
||||
*
|
||||
* Used by a driver to report its performance characteristics.
|
||||
*/
|
||||
struct PerformanceInfo {
|
||||
/**
|
||||
* Ratio of the time taken by the driver to execute the
|
||||
* workload compared to the time the CPU would take for the
|
||||
* same workload. A lower number is better.
|
||||
*/
|
||||
float execTime;
|
||||
|
||||
/**
|
||||
* Ratio of the energy used by the driver compared to what
|
||||
* the CPU would use for doing the same workload. A lower number
|
||||
* is better.
|
||||
*/
|
||||
float powerUsage;
|
||||
};
|
||||
|
||||
/**
|
||||
* The capabilities of a driver.
|
||||
*/
|
||||
struct Capabilities {
|
||||
/**
|
||||
* Driver performance when operating on float32 data.
|
||||
*/
|
||||
PerformanceInfo float32Performance;
|
||||
|
||||
/**
|
||||
* Driver performance when operating on asymmetric 8-bit quantized data.
|
||||
*/
|
||||
PerformanceInfo quantized8Performance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the location of a data object.
|
||||
*/
|
||||
struct DataLocation {
|
||||
/**
|
||||
* The index of the memory pool where this location is found.
|
||||
*/
|
||||
uint32_t poolIndex;
|
||||
|
||||
/**
|
||||
* Offset in bytes from the start of the pool.
|
||||
*/
|
||||
uint32_t offset;
|
||||
|
||||
/**
|
||||
* The length of the data in bytes.
|
||||
*/
|
||||
uint32_t length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes one operand of the model's graph.
|
||||
*/
|
||||
struct Operand {
|
||||
/**
|
||||
* Data type of the operand.
|
||||
*/
|
||||
OperandType type;
|
||||
|
||||
/**
|
||||
* Dimensions of the operand.
|
||||
*
|
||||
* For a scalar operand, dimensions.size() must be 0.
|
||||
*
|
||||
* For a tensor operand, dimensions.size() must be at least 1;
|
||||
* however, any of the dimensions may be unspecified.
|
||||
*
|
||||
* A tensor operand with all dimensions specified has "fully
|
||||
* specified" dimensions. Whenever possible (i.e., whenever the
|
||||
* dimensions are known at model construction time), a tensor
|
||||
* operand should have (but is not required to have) fully
|
||||
* specified dimensions, in order to enable the best possible
|
||||
* performance.
|
||||
*
|
||||
* If a tensor operand's dimensions are not fully specified, the
|
||||
* dimensions of the operand are deduced from the operand
|
||||
* dimensions and values of the operation for which that operand
|
||||
* is an output.
|
||||
*
|
||||
* In the following situations, a tensor operand's dimensions must
|
||||
* be fully specified:
|
||||
*
|
||||
* . The operand has lifetime CONSTANT_COPY or
|
||||
* CONSTANT_REFERENCE.
|
||||
*
|
||||
* . The operand has lifetime MODEL_INPUT or MODEL_OUTPUT. Fully
|
||||
* specified dimensions must either be present in the
|
||||
* Operand or they must be provided in the corresponding
|
||||
* RequestArgument.
|
||||
* EXCEPTION: If the input or output is optional and omitted
|
||||
* (by setting the hasNoValue field of the corresponding
|
||||
* RequestArgument to true) then it need not have fully
|
||||
* specified dimensions.
|
||||
*
|
||||
* A tensor operand with some number of unspecified dimensions is
|
||||
* represented by setting each unspecified dimension to 0.
|
||||
*/
|
||||
vec<uint32_t> dimensions;
|
||||
|
||||
/**
|
||||
* The number of times this operand appears as an operation input.
|
||||
*
|
||||
* (For example, if this operand appears once in one operation's
|
||||
* input list, and three times in another operation's input list,
|
||||
* then numberOfConsumers = 4.)
|
||||
*/
|
||||
uint32_t numberOfConsumers;
|
||||
|
||||
/**
|
||||
* Quantized scale of the operand.
|
||||
*
|
||||
* Only applicable if the operand is of type TENSOR_QUANT8_ASYMM or
|
||||
* TENSOR_INT32.
|
||||
*/
|
||||
float scale;
|
||||
|
||||
/**
|
||||
* Quantized zero-point offset of the operand.
|
||||
*
|
||||
* Only applicable if the operand is of type TENSOR_QUANT8_ASYMM.
|
||||
*/
|
||||
int32_t zeroPoint;
|
||||
|
||||
/**
|
||||
* How the operand is used.
|
||||
*/
|
||||
OperandLifeTime lifetime;
|
||||
|
||||
/**
|
||||
* Where to find the data for this operand.
|
||||
* If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, MODEL_OUTPUT, or
|
||||
* NO_VALUE:
|
||||
* - All the fields must be 0.
|
||||
* If the lifetime is CONSTANT_COPY:
|
||||
* - location.poolIndex is 0.
|
||||
* - location.offset is the offset in bytes into Model.operandValues.
|
||||
* - location.length is set.
|
||||
* If the lifetime is CONSTANT_REFERENCE:
|
||||
* - location.poolIndex is set.
|
||||
* - location.offset is the offset in bytes into the specified pool.
|
||||
* - location.length is set.
|
||||
*/
|
||||
DataLocation location;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes one operation of the model's graph.
|
||||
*/
|
||||
struct Operation {
|
||||
/**
|
||||
* The operation type.
|
||||
*/
|
||||
OperationType type;
|
||||
|
||||
/**
|
||||
* Describes the table that contains the indexes of the inputs of the
|
||||
* operation. The offset is the index in the operandIndexes table.
|
||||
*/
|
||||
vec<uint32_t> inputs;
|
||||
|
||||
/**
|
||||
* Describes the table that contains the indexes of the outputs of the
|
||||
* operation. The offset is the index in the operandIndexes table.
|
||||
*/
|
||||
vec<uint32_t> outputs;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Neural Network Model.
|
||||
*
|
||||
* This includes not only the execution graph, but also constant data such as
|
||||
* weights or scalars added at construction time. The only information that
|
||||
* might not be known is the shape of the input tensors.
|
||||
*/
|
||||
struct Model {
|
||||
/**
|
||||
* All operands included in the model.
|
||||
*/
|
||||
vec<Operand> operands;
|
||||
|
||||
/**
|
||||
* All operations included in the model.
|
||||
*
|
||||
* The operations are sorted into execution order. Every operand
|
||||
* with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
|
||||
* written before it is read.
|
||||
*/
|
||||
vec<Operation> operations;
|
||||
|
||||
/**
|
||||
* Input indexes of the model. There must be at least one.
|
||||
*
|
||||
* Each value corresponds to the index of the operand in "operands".
|
||||
*/
|
||||
vec<uint32_t> inputIndexes;
|
||||
|
||||
/**
|
||||
* Output indexes of the model. There must be at least one.
|
||||
*
|
||||
* Each value corresponds to the index of the operand in "operands".
|
||||
*/
|
||||
vec<uint32_t> outputIndexes;
|
||||
|
||||
/**
|
||||
* A byte buffer containing operand data that were copied into the model.
|
||||
*
|
||||
* An operand's value must be located here if and only if Operand::lifetime
|
||||
* equals OperandLifeTime::CONSTANT_COPY.
|
||||
*/
|
||||
vec<uint8_t> operandValues;
|
||||
|
||||
/**
|
||||
* A collection of shared memory pools containing operand values.
|
||||
*
|
||||
* An operand's value must be located here if and only if Operand::lifetime
|
||||
* equals OperandLifeTime::CONSTANT_REFERENCE.
|
||||
*/
|
||||
vec<memory> pools;
|
||||
};
|
||||
|
||||
/**
|
||||
* Metadata information specifying the location of the input or output data and
|
||||
* any updates to the input or output operand.
|
||||
*/
|
||||
struct RequestArgument {
|
||||
/**
|
||||
* If true, the argument does not have a value. This can be used for
|
||||
* operations that take optional arguments. If true, the fields of location
|
||||
* are set to 0 and the dimensions vector is left empty.
|
||||
*/
|
||||
bool hasNoValue;
|
||||
|
||||
/**
|
||||
* The location within one of the memory pools passed in the Request.
|
||||
*/
|
||||
DataLocation location;
|
||||
|
||||
/**
|
||||
* Updated dimension information.
|
||||
*
|
||||
* If dimensions.size() > 0, dimension information was provided
|
||||
* along with the argument. This can be the case for models that
|
||||
* accept inputs of varying size. This can't change the rank, just
|
||||
* the value of the dimensions that were unspecified in the
|
||||
* model. If dimensions.size() > 0, then all dimensions must be
|
||||
* specified here; and any dimension that was specified in the
|
||||
* model must have the same value here.
|
||||
*
|
||||
* If the dimensions in the model are not fully specified, then
|
||||
* they must be fully specified here, unless hasNoValue is set to
|
||||
* true. If the dimensions in the model are fully specified, then
|
||||
* either dimensions.size() may be 0, or the dimensions in the
|
||||
* model must be identical to the dimensions here.
|
||||
*/
|
||||
vec<uint32_t> dimensions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inputs to be sent to and outputs to be retrieved from a prepared model.
|
||||
*
|
||||
* A Request serves two primary tasks:
|
||||
* 1) Provides the input and output data to be used when executing the model.
|
||||
* 2) Specifies any updates to the input operand metadata that were left
|
||||
* unspecified at model preparation time.
|
||||
*
|
||||
* An output must not overlap with any other output, with an input, or
|
||||
* with an operand of lifetime CONSTANT_REFERENCE.
|
||||
*/
|
||||
struct Request {
|
||||
/**
|
||||
* Input data and information to be used in the execution of a prepared
|
||||
* model.
|
||||
*
|
||||
* The index of the input corresponds to the index in Model.inputIndexes.
|
||||
* E.g., input[i] corresponds to Model.inputIndexes[i].
|
||||
*/
|
||||
vec<RequestArgument> inputs;
|
||||
|
||||
/**
|
||||
* Output data and information to be used in the execution of a prepared
|
||||
* model.
|
||||
*
|
||||
* The index of the output corresponds to the index in Model.outputIndexes.
|
||||
* E.g., output[i] corresponds to Model.outputIndexes[i].
|
||||
*/
|
||||
vec<RequestArgument> outputs;
|
||||
|
||||
/**
|
||||
* A collection of shared memory pools containing operand data for both the
|
||||
* inputs and the outputs to a model.
|
||||
*/
|
||||
vec<memory> pools;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return status of a function.
|
||||
*/
|
||||
enum ErrorStatus : int32_t {
|
||||
NONE,
|
||||
DEVICE_UNAVAILABLE,
|
||||
GENERAL_FAILURE,
|
||||
OUTPUT_INSUFFICIENT_SIZE,
|
||||
INVALID_ARGUMENT,
|
||||
};
|
||||
@@ -26,7 +26,6 @@ import @1.0::PerformanceInfo;
|
||||
* The type of an operation in a model.
|
||||
*/
|
||||
enum OperationType : @1.0::OperationType {
|
||||
|
||||
/**
|
||||
* BatchToSpace for N-dimensional tensors.
|
||||
*
|
||||
@@ -41,7 +40,8 @@ enum OperationType : @1.0::OperationType {
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
*
|
||||
* Supported tensor rank: 4
|
||||
* Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width,
|
||||
* and Channels) data layout.
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: An n-D tensor, specifying the tensor to be reshaped
|
||||
@@ -51,8 +51,8 @@ enum OperationType : @1.0::OperationType {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: A tensor of the same {@link OperandType} as input0.
|
||||
*
|
||||
* Available since API level 28.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
BATCH_TO_SPACE_ND = 29,
|
||||
|
||||
@@ -91,8 +91,6 @@ enum OperationType : @1.0::OperationType {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: A tensor of the same {@link OperandType} as input0.
|
||||
*
|
||||
* Available since API level 28.
|
||||
*/
|
||||
DIV = 30,
|
||||
|
||||
@@ -126,8 +124,8 @@ enum OperationType : @1.0::OperationType {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: A tensor of the same {@link OperandType} as input0.
|
||||
*
|
||||
* Available since API level 28.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be same as input0.
|
||||
*/
|
||||
MEAN = 31,
|
||||
|
||||
@@ -138,7 +136,8 @@ enum OperationType : @1.0::OperationType {
|
||||
*
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM} (the pad value is undefined)
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
* (the pad value is undefined)
|
||||
*
|
||||
* Supported tensor rank: up to 4
|
||||
*
|
||||
@@ -160,11 +159,8 @@ enum OperationType : @1.0::OperationType {
|
||||
* of the padding:
|
||||
* output0.dimension[i] =
|
||||
* padding[i, 0] + input0.dimension[i] + padding[i, 1]
|
||||
*
|
||||
* NOTE: The pad value for {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
|
||||
* is undefined.
|
||||
*
|
||||
* Available since API level 28.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
PAD = 32,
|
||||
|
||||
@@ -182,8 +178,10 @@ enum OperationType : @1.0::OperationType {
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
* (the pad value is undefined)
|
||||
*
|
||||
* Supported tensor rank: 4
|
||||
* Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width,
|
||||
* and Channels) data layout.
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: An n-D tensor, specifying the input.
|
||||
@@ -201,8 +199,8 @@ enum OperationType : @1.0::OperationType {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: A tensor of the same {@link OperandType} as input0.
|
||||
*
|
||||
* Available since API level 28.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
SPACE_TO_BATCH_ND = 33,
|
||||
|
||||
@@ -232,8 +230,8 @@ enum OperationType : @1.0::OperationType {
|
||||
* * 0: A tensor of the same {@link OperandType} as input0. Contains the
|
||||
* same data as input, but has one or more dimensions of size 1
|
||||
* removed.
|
||||
*
|
||||
* Available since API level 28.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
SQUEEZE = 34,
|
||||
|
||||
@@ -278,8 +276,8 @@ enum OperationType : @1.0::OperationType {
|
||||
* Outputs:
|
||||
* * 0: A tensor of the same {@link OperandType} as input0 and rank (n - k),
|
||||
* where k is the number of bits set in shrink_axis_mask.
|
||||
*
|
||||
* Available since API level 28.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
STRIDED_SLICE = 35,
|
||||
|
||||
@@ -318,8 +316,6 @@ enum OperationType : @1.0::OperationType {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: A tensor of the same {@link OperandType} as input0.
|
||||
*
|
||||
* Available since API level 28.
|
||||
*/
|
||||
SUB = 36,
|
||||
|
||||
@@ -345,11 +341,10 @@ enum OperationType : @1.0::OperationType {
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: A tensor of the same {@link OperandType} as input0.
|
||||
*
|
||||
* Available since API level 28.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
TRANSPOSE = 37,
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
158
neuralnetworks/1.1/types.t
Normal file
158
neuralnetworks/1.1/types.t
Normal file
@@ -0,0 +1,158 @@
|
||||
%% template file for generating types.hal.
|
||||
%% see frameworks/ml/nn/tools/api/README.md.
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.neuralnetworks@1.1;
|
||||
|
||||
import @1.0::Operand;
|
||||
import @1.0::OperationType;
|
||||
import @1.0::PerformanceInfo;
|
||||
|
||||
/**
|
||||
* Operation types.
|
||||
*
|
||||
* The type of an operation in a model.
|
||||
*/
|
||||
enum OperationType : @1.0::OperationType {
|
||||
%insert Operation_1.1
|
||||
};
|
||||
|
||||
/**
|
||||
* The capabilities of a driver.
|
||||
*/
|
||||
struct Capabilities {
|
||||
/**
|
||||
* Driver performance when operating on float32 data.
|
||||
*/
|
||||
PerformanceInfo float32Performance;
|
||||
|
||||
/**
|
||||
* Driver performance when operating on asymmetric 8-bit quantized data.
|
||||
*/
|
||||
PerformanceInfo quantized8Performance;
|
||||
|
||||
/**
|
||||
* Driver performance when operating on float32 data but performing
|
||||
* calculations with range and/or precision as low as that of the IEEE
|
||||
* 754 16-bit floating-point format.
|
||||
*/
|
||||
PerformanceInfo relaxedFloat32toFloat16Performance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes one operation of the model's graph.
|
||||
*/
|
||||
struct Operation {
|
||||
/**
|
||||
* The operation type.
|
||||
*/
|
||||
OperationType type;
|
||||
|
||||
/**
|
||||
* Describes the table that contains the indexes of the inputs of the
|
||||
* operation. The offset is the index in the operandIndexes table.
|
||||
*/
|
||||
vec<uint32_t> inputs;
|
||||
|
||||
/**
|
||||
* Describes the table that contains the indexes of the outputs of the
|
||||
* operation. The offset is the index in the operandIndexes table.
|
||||
*/
|
||||
vec<uint32_t> outputs;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Neural Network Model.
|
||||
*
|
||||
* This includes not only the execution graph, but also constant data such as
|
||||
* weights or scalars added at construction time. The only information that
|
||||
* may not be known is the shape of the input tensors.
|
||||
*/
|
||||
struct Model {
|
||||
/**
|
||||
* All operands included in the model.
|
||||
*/
|
||||
vec<Operand> operands;
|
||||
|
||||
/**
|
||||
* All operations included in the model.
|
||||
*
|
||||
* The operations are sorted into execution order. Every operand
|
||||
* with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
|
||||
* written before it is read.
|
||||
*/
|
||||
vec<Operation> operations;
|
||||
|
||||
/**
|
||||
* Input indexes of the model. There must be at least one.
|
||||
*
|
||||
* Each value corresponds to the index of the operand in "operands".
|
||||
*/
|
||||
vec<uint32_t> inputIndexes;
|
||||
|
||||
/**
|
||||
* Output indexes of the model. There must be at least one.
|
||||
*
|
||||
* Each value corresponds to the index of the operand in "operands".
|
||||
*/
|
||||
vec<uint32_t> outputIndexes;
|
||||
|
||||
/**
|
||||
* A byte buffer containing operand data that were copied into the model.
|
||||
*
|
||||
* An operand's value must be located here if and only if Operand::lifetime
|
||||
* equals OperandLifeTime::CONSTANT_COPY.
|
||||
*/
|
||||
vec<uint8_t> operandValues;
|
||||
|
||||
/**
|
||||
* A collection of shared memory pools containing operand values.
|
||||
*
|
||||
* An operand's value must be located here if and only if Operand::lifetime
|
||||
* equals OperandLifeTime::CONSTANT_REFERENCE.
|
||||
*/
|
||||
vec<memory> pools;
|
||||
|
||||
/**
|
||||
* 'true' indicates TENSOR_FLOAT32 may be calculated with range and/or
|
||||
* precision as low as that of the IEEE 754 16-bit floating-point format.
|
||||
* 'false' indicates TENSOR_FLOAT32 must be calculated using at least the
|
||||
* range and precision of the IEEE 754 32-bit floating-point format.
|
||||
*/
|
||||
bool relaxComputationFloat32toFloat16;
|
||||
};
|
||||
|
||||
/**
|
||||
* Execution preferences.
|
||||
*/
|
||||
enum ExecutionPreference : int32_t {
|
||||
/**
|
||||
* Prefer executing in a way that minimizes battery drain.
|
||||
* This is desirable for compilations that will be executed often.
|
||||
*/
|
||||
LOW_POWER = 0,
|
||||
/**
|
||||
* Prefer returning a single answer as fast as possible, even if this causes
|
||||
* more power consumption.
|
||||
*/
|
||||
FAST_SINGLE_ANSWER = 1,
|
||||
/**
|
||||
* Prefer maximizing the throughput of successive frames, for example when
|
||||
* processing successive frames coming from the camera.
|
||||
*/
|
||||
SUSTAINED_SPEED = 2,
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
745
neuralnetworks/1.2/types.t
Normal file
745
neuralnetworks/1.2/types.t
Normal file
@@ -0,0 +1,745 @@
|
||||
%% template file for generating types.hal.
|
||||
%% see frameworks/ml/nn/tools/api/README.md.
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.neuralnetworks@1.2;
|
||||
|
||||
import @1.0::DataLocation;
|
||||
import @1.0::ErrorStatus;
|
||||
import @1.0::OperandLifeTime;
|
||||
import @1.0::OperandType;
|
||||
import @1.0::PerformanceInfo;
|
||||
import @1.1::OperationType;
|
||||
|
||||
import android.hidl.safe_union@1.0::Monostate;
|
||||
|
||||
enum Constant : uint32_t {
|
||||
/**
|
||||
* The byte size of the cache token.
|
||||
*/
|
||||
BYTE_SIZE_OF_CACHE_TOKEN = 32,
|
||||
|
||||
/**
|
||||
* The maximum number of files for each type of cache in compilation caching.
|
||||
*/
|
||||
MAX_NUMBER_OF_CACHE_FILES = 32,
|
||||
};
|
||||
|
||||
enum OperandType : @1.0::OperandType {
|
||||
%insert Operand_1.2
|
||||
|
||||
/*
|
||||
* DEPRECATED. Since HAL version 1.2, extensions are the preferred
|
||||
* alternative to OEM operation and data types.
|
||||
*
|
||||
* OEM specific scalar value.
|
||||
* OEM = 10000,
|
||||
*/
|
||||
/*
|
||||
* DEPRECATED. Since HAL version 1.2, extensions are the preferred
|
||||
* alternative to OEM operation and data types.
|
||||
*
|
||||
* A tensor of OEM specific values.
|
||||
* TENSOR_OEM_BYTE = 10001,
|
||||
*/
|
||||
/* ADDING A NEW FUNDAMENTAL TYPE REQUIRES UPDATING THE VALUE OF
|
||||
* OperandTypeRange::FUNDAMENTAL_MAX.
|
||||
*/
|
||||
/* ADDING A NEW OEM TYPE REQUIRES UPDATING THE VALUE OF
|
||||
* OperandTypeRange::OEM_MAX.
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* The range of operand values in the OperandType enum.
|
||||
*/
|
||||
enum OperandTypeRange : uint32_t {
|
||||
BASE_MIN = 0,
|
||||
FUNDAMENTAL_MIN = 0,
|
||||
%insert Operand_1.2_MAX
|
||||
OEM_MIN = 10000,
|
||||
OEM_MAX = 10001,
|
||||
BASE_MAX = 0xFFFF,
|
||||
};
|
||||
|
||||
/**
|
||||
* Operation types.
|
||||
*
|
||||
* The type of an operation in a model.
|
||||
*/
|
||||
enum OperationType : int32_t {
|
||||
|
||||
%insert Operation_1.0
|
||||
|
||||
%insert Operation_1.1
|
||||
|
||||
%insert Operation_1.2
|
||||
|
||||
/**
|
||||
* DEPRECATED. Since NNAPI 1.2, extensions are the preferred alternative to
|
||||
* OEM operation and data types.
|
||||
*
|
||||
* This operation is OEM specific. It should only be used for OEM
|
||||
* applications.
|
||||
*/
|
||||
OEM_OPERATION = @1.1::OperationType:OEM_OPERATION,
|
||||
/* ADDING A NEW FUNDAMENTAL OPERATION REQUIRES UPDATING THE VALUE OF
|
||||
* OperationTypeRange::FUNDAMENTAL_MAX.
|
||||
*/
|
||||
/* ADDING A NEW OEM OPERATION REQUIRES UPDATING THE VALUE OF
|
||||
* OperationTypeRange::OEM_MAX.
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* The range of values in the OperationType enum.
|
||||
*/
|
||||
enum OperationTypeRange : uint32_t {
|
||||
BASE_MIN = 0,
|
||||
FUNDAMENTAL_MIN = 0,
|
||||
%insert Operation_1.2_MAX
|
||||
OEM_MIN = 10000,
|
||||
OEM_MAX = 10000,
|
||||
BASE_MAX = 0xFFFF,
|
||||
};
|
||||
|
||||
/**
|
||||
* Device types.
|
||||
*
|
||||
* The type of NNAPI device.
|
||||
*/
|
||||
enum DeviceType : int32_t {
|
||||
// Leaving 0 unused as it means unknown type in NDK NNAPI. There is no
|
||||
// HAL equivalent of unknown type and a 1.2 HAL implementation must belong
|
||||
// to one of the categories below.
|
||||
/** The device does not fall into any category below. */
|
||||
OTHER = 1,
|
||||
/** The device runs NNAPI models on single or multi-core CPU. */
|
||||
CPU = 2,
|
||||
/** The device can run NNAPI models and also accelerate graphics APIs such
|
||||
* as OpenGL ES and Vulkan. */
|
||||
GPU = 3,
|
||||
/** Dedicated accelerator for Machine Learning workloads. */
|
||||
ACCELERATOR = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* The capabilities of a driver.
|
||||
*
|
||||
* Performance of an operation comes from the type of its first operand.
|
||||
* This represents performance for non extension operand types.
|
||||
*/
|
||||
struct Capabilities {
|
||||
/**
|
||||
* Driver performance when operating on float32 data but performing
|
||||
* calculations with range and/or precision as low as that of the IEEE
|
||||
* 754 16-bit floating-point format.
|
||||
*/
|
||||
PerformanceInfo relaxedFloat32toFloat16PerformanceScalar;
|
||||
PerformanceInfo relaxedFloat32toFloat16PerformanceTensor;
|
||||
|
||||
/**
|
||||
* Driver performance when operating on a particular data type.
|
||||
* In the case of float32 data, this is used when the calculations
|
||||
* are not relaxed.
|
||||
*/
|
||||
struct OperandPerformance {
|
||||
OperandType type;
|
||||
PerformanceInfo info;
|
||||
};
|
||||
|
||||
/**
|
||||
* Performance by operand type. Must be sorted by OperandType.
|
||||
* If a particular OperandType is not present in operandPerformance,
|
||||
* its performance is treated as { .execTime = FLT_MAX, .powerUsage = FLT_MAX }.
|
||||
*/
|
||||
vec<OperandPerformance> operandPerformance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes one operation of the model's graph.
|
||||
*/
|
||||
struct Operation {
|
||||
/**
|
||||
* The operation type.
|
||||
*
|
||||
* Besides the values listed in {@link OperationType}, any value above
|
||||
* {@link OperationTypeRange::BASE_MAX} is possible and should be interpreted
|
||||
* as an extension type according to {@link Model::extensionNameToPrefix}.
|
||||
*/
|
||||
OperationType type;
|
||||
|
||||
/**
|
||||
* Describes the table that contains the indexes of the inputs of the
|
||||
* operation. The offset is the index in the operandIndexes table.
|
||||
*/
|
||||
vec<uint32_t> inputs;
|
||||
|
||||
/**
|
||||
* Describes the table that contains the indexes of the outputs of the
|
||||
* operation. The offset is the index in the operandIndexes table.
|
||||
*/
|
||||
vec<uint32_t> outputs;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parameters for TENSOR_QUANT8_SYMM_PER_CHANNEL operand.
|
||||
*/
|
||||
struct SymmPerChannelQuantParams {
|
||||
/** Array of scaling values for each channel. Each value must be greater than zero. */
|
||||
vec<float> scales;
|
||||
/** Index of the channel dimension */
|
||||
uint32_t channelDim;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes one operand of the model's graph.
|
||||
*/
|
||||
struct Operand {
|
||||
/**
|
||||
* The data type.
|
||||
*
|
||||
* Besides the values listed in {@link OperandType}, any value above
|
||||
* {@link OperandTypeRange::BASE_MAX} is possible and should be interpreted
|
||||
* as an extension type according to {@link Model::extensionNameToPrefix}.
|
||||
*/
|
||||
OperandType type;
|
||||
|
||||
/**
|
||||
* Dimensions of the operand.
|
||||
*
|
||||
* For a scalar operand, dimensions.size() must be 0.
|
||||
*
|
||||
* A tensor operand with all dimensions specified has "fully
|
||||
* specified" dimensions. Whenever possible (i.e., whenever the
|
||||
* dimensions are known at model construction time), a tensor
|
||||
* operand should have (but is not required to have) fully
|
||||
* specified dimensions, in order to enable the best possible
|
||||
* performance.
|
||||
*
|
||||
* If a tensor operand's dimensions are not fully specified, the
|
||||
* dimensions of the operand are deduced from the operand
|
||||
* dimensions and values of the operation for which that operand
|
||||
* is an output.
|
||||
*
|
||||
* In the following situations, a tensor operand's dimensions must
|
||||
* be fully specified:
|
||||
*
|
||||
* . The operand has lifetime CONSTANT_COPY or
|
||||
* CONSTANT_REFERENCE.
|
||||
*
|
||||
* . The operand has lifetime MODEL_INPUT. Fully
|
||||
* specified dimensions must either be present in the
|
||||
* Operand or they must be provided in the corresponding
|
||||
* RequestArgument.
|
||||
* EXCEPTION: If the input is optional and omitted
|
||||
* (by setting the hasNoValue field of the corresponding
|
||||
* RequestArgument to true) then it need not have fully
|
||||
* specified dimensions.
|
||||
*
|
||||
* A tensor operand with some number of unspecified dimensions is
|
||||
* represented by setting each unspecified dimension to 0.
|
||||
*
|
||||
* A tensor operand with unspecified rank is represented by providing
|
||||
* an empty dimensions vector.
|
||||
*/
|
||||
vec<uint32_t> dimensions;
|
||||
|
||||
/**
|
||||
* The number of times this operand appears as an operation input.
|
||||
*
|
||||
* (For example, if this operand appears once in one operation's
|
||||
* input list, and three times in another operation's input list,
|
||||
* then numberOfConsumers = 4.)
|
||||
*/
|
||||
uint32_t numberOfConsumers;
|
||||
|
||||
/**
|
||||
* Quantized scale of the operand.
|
||||
*
|
||||
* Only applicable if the operand is of type TENSOR_QUANT8_ASYMM or
|
||||
* TENSOR_INT32.
|
||||
*/
|
||||
float scale;
|
||||
|
||||
/**
|
||||
* Quantized zero-point offset of the operand.
|
||||
*
|
||||
* Only applicable if the operand is of type TENSOR_QUANT8_ASYMM.
|
||||
*/
|
||||
int32_t zeroPoint;
|
||||
|
||||
/**
|
||||
* How the operand is used.
|
||||
*/
|
||||
OperandLifeTime lifetime;
|
||||
|
||||
/**
|
||||
* Where to find the data for this operand.
|
||||
* If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, MODEL_OUTPUT, or
|
||||
* NO_VALUE:
|
||||
* - All the fields must be 0.
|
||||
* If the lifetime is CONSTANT_COPY:
|
||||
* - location.poolIndex is 0.
|
||||
* - location.offset is the offset in bytes into Model.operandValues.
|
||||
* - location.length is set.
|
||||
* If the lifetime is CONSTANT_REFERENCE:
|
||||
* - location.poolIndex is set.
|
||||
* - location.offset is the offset in bytes into the specified pool.
|
||||
* - location.length is set.
|
||||
*/
|
||||
DataLocation location;
|
||||
|
||||
/**
|
||||
* Additional parameters specific to a particular operand type.
|
||||
*/
|
||||
safe_union ExtraParams {
|
||||
/**
|
||||
* No additional parameters.
|
||||
*/
|
||||
Monostate none;
|
||||
|
||||
/**
|
||||
* Symmetric per-channel quantization parameters.
|
||||
*
|
||||
* Only applicable to operands of type TENSOR_QUANT8_SYMM_PER_CHANNEL.
|
||||
*/
|
||||
SymmPerChannelQuantParams channelQuant;
|
||||
|
||||
/**
|
||||
* Extension operand parameters.
|
||||
*
|
||||
* The framework treats this as an opaque data blob.
|
||||
* The format is up to individual extensions.
|
||||
*/
|
||||
vec<uint8_t> extension;
|
||||
} extraParams;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Neural Network Model.
|
||||
*
|
||||
* This includes not only the execution graph, but also constant data such as
|
||||
* weights or scalars added at construction time. The only information that
|
||||
* may not be known is the shape of the input tensors.
|
||||
*/
|
||||
struct Model {
|
||||
/**
|
||||
* All operands included in the model.
|
||||
*/
|
||||
vec<Operand> operands;
|
||||
|
||||
/**
|
||||
* All operations included in the model.
|
||||
*
|
||||
* The operations are sorted into execution order. Every operand
|
||||
* with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
|
||||
* written before it is read.
|
||||
*/
|
||||
vec<Operation> operations;
|
||||
|
||||
/**
|
||||
* Input indexes of the model. There must be at least one.
|
||||
*
|
||||
* Each value corresponds to the index of the operand in "operands".
|
||||
*/
|
||||
vec<uint32_t> inputIndexes;
|
||||
|
||||
/**
|
||||
* Output indexes of the model. There must be at least one.
|
||||
*
|
||||
* Each value corresponds to the index of the operand in "operands".
|
||||
*/
|
||||
vec<uint32_t> outputIndexes;
|
||||
|
||||
/**
|
||||
* A byte buffer containing operand data that were copied into the model.
|
||||
*
|
||||
* An operand's value must be located here if and only if Operand::lifetime
|
||||
* equals OperandLifeTime::CONSTANT_COPY.
|
||||
*/
|
||||
vec<uint8_t> operandValues;
|
||||
|
||||
/**
|
||||
* A collection of shared memory pools containing operand values.
|
||||
*
|
||||
* An operand's value must be located here if and only if Operand::lifetime
|
||||
* equals OperandLifeTime::CONSTANT_REFERENCE.
|
||||
*/
|
||||
vec<memory> pools;
|
||||
|
||||
/**
|
||||
* 'true' indicates TENSOR_FLOAT32 may be calculated with range and/or
|
||||
* precision as low as that of the IEEE 754 16-bit floating-point format.
|
||||
* 'false' indicates TENSOR_FLOAT32 must be calculated using at least the
|
||||
* range and precision of the IEEE 754 32-bit floating-point format.
|
||||
*/
|
||||
bool relaxComputationFloat32toFloat16;
|
||||
|
||||
/**
|
||||
* The mapping between extension names and prefixes of operand and
|
||||
* operation type values.
|
||||
*
|
||||
* An operand or operation whose numeric type value is above
|
||||
* {@link OperandTypeRange::BASE_MAX} or
|
||||
* {@link OperationTypeRange::BASE_MAX} respectively should be interpreted
|
||||
* as an extension operand. The low
|
||||
* {@link Model::ExtensionTypeEncoding::LOW_BITS_TYPE} bits of the value
|
||||
* correspond to the type ID within the extension and the high
|
||||
* {@link Model::ExtensionTypeEncoding::HIGH_BITS_PREFIX} bits encode
|
||||
* the "prefix", which maps uniquely to the extension name.
|
||||
*
|
||||
* For example, if a model contains an operation whose value is
|
||||
* 0xAAAABBBB and extensionNameToPrefix contains an entry with
|
||||
* prefix=0xAAAA and name="vendor.test.test_extension", then
|
||||
* the operation should be interpreted as the operation 0xBBBB
|
||||
* of the extension named vendor.test.test_extension.
|
||||
*
|
||||
* This is a one-to-one correspondence. That is, there must be at most one
|
||||
* prefix corresponding to each extension name and at most one extension
|
||||
* name corresponding to each prefix.
|
||||
*/
|
||||
vec<ExtensionNameAndPrefix> extensionNameToPrefix;
|
||||
|
||||
/**
|
||||
* A correspondence between an extension name and a prefix of operand and
|
||||
* operation type values.
|
||||
*/
|
||||
struct ExtensionNameAndPrefix {
|
||||
/**
|
||||
* The extension name.
|
||||
*
|
||||
* See {@link Extension::name} for the format specification.
|
||||
*/
|
||||
string name;
|
||||
|
||||
/**
|
||||
* The unique extension identifier within the model.
|
||||
*
|
||||
* See {@link Model::extensionNameToPrefix}.
|
||||
*/
|
||||
uint16_t prefix;
|
||||
};
|
||||
|
||||
/**
|
||||
* Numeric values of extension operand and operation types have the
|
||||
* following structure:
|
||||
* - 16 high bits represent the "prefix", which corresponds uniquely to the
|
||||
* extension name.
|
||||
* - 16 low bits represent the type ID within the extension.
|
||||
*/
|
||||
enum ExtensionTypeEncoding : uint8_t {
|
||||
HIGH_BITS_PREFIX = 16,
|
||||
LOW_BITS_TYPE = 16,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the shape information of an output operand after execution.
|
||||
*/
|
||||
struct OutputShape {
|
||||
/**
|
||||
* Dimensions of the operand.
|
||||
*/
|
||||
vec<uint32_t> dimensions;
|
||||
|
||||
/**
|
||||
* Whether the provided buffer size is sufficient for the output.
|
||||
*/
|
||||
bool isSufficient;
|
||||
};
|
||||
|
||||
/**
|
||||
* Specifies whether or not to measure timing information during execution.
|
||||
*/
|
||||
enum MeasureTiming : int32_t {
|
||||
NO = 0,
|
||||
YES = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
* Timing information measured during execution. Each time is a duration from
|
||||
* the beginning of some task to the end of that task, including time when that
|
||||
* task is not active (for example, preempted by some other task, or
|
||||
* waiting for some resource to become available).
|
||||
*
|
||||
* Times are measured in microseconds.
|
||||
* When a time is not available, it must be reported as UINT64_MAX.
|
||||
*/
|
||||
struct Timing {
|
||||
/** Execution time on device (not driver, which runs on host processor). */
|
||||
uint64_t timeOnDevice;
|
||||
/** Execution time in driver (including time on device). */
|
||||
uint64_t timeInDriver;
|
||||
};
|
||||
|
||||
/**
|
||||
* FmqRequestDatum is a single element of a serialized representation of an
|
||||
* execution request (a {@link @1.0::Request} object and a {@link MeasureTiming}
|
||||
* value) which is sent across FastMessageQueue.
|
||||
*
|
||||
* The serialized representation for a particular execution is referred to later
|
||||
* in these descriptions as a 'packet'.
|
||||
*
|
||||
* FastMessageQueue can only pass HIDL-defined types that do not involve nested
|
||||
* buffers, handles, or interfaces.
|
||||
*
|
||||
* The request is serialized as follows:
|
||||
* 1) 'packetInformation'
|
||||
* 2) For each input operand:
|
||||
* 2.1) 'inputOperandInformation'
|
||||
* 2.2) For each dimension element of the operand:
|
||||
* 2.2.1) 'inputOperandDimensionValue'
|
||||
* 3) For each output operand:
|
||||
* 3.1) 'outputOperandInformation'
|
||||
* 3.2) For each dimension element of the operand:
|
||||
* 3.2.1) 'outputOperandDimensionValue'
|
||||
* 4) For each pool:
|
||||
* 4.1) 'poolIdentifier'
|
||||
* 5) 'measureTiming'
|
||||
*/
|
||||
safe_union FmqRequestDatum {
|
||||
/**
|
||||
* Type to describe the high-level layout of the packet.
|
||||
*/
|
||||
struct PacketInformation {
|
||||
/**
|
||||
* How many elements the packet contains, including the
|
||||
* "packetInformation" datum.
|
||||
*/
|
||||
uint32_t packetSize;
|
||||
|
||||
/**
|
||||
* Number of input operands.
|
||||
*/
|
||||
uint32_t numberOfInputOperands;
|
||||
|
||||
/**
|
||||
* Number of output operands.
|
||||
*/
|
||||
uint32_t numberOfOutputOperands;
|
||||
|
||||
/**
|
||||
* Number of pool identifiers.
|
||||
*/
|
||||
uint32_t numberOfPools;
|
||||
};
|
||||
|
||||
/**
|
||||
* Type representing the information for each operand.
|
||||
*/
|
||||
struct OperandInformation {
|
||||
/**
|
||||
* If true, the argument does not have a value. This can be used for
|
||||
* operations that take optional arguments. If true, the fields of
|
||||
* 'location' are set to 0, 'numberOfDimensions' is set to 0, and the
|
||||
* dimensions information is omitted from the serialization.
|
||||
*/
|
||||
bool hasNoValue;
|
||||
|
||||
/**
|
||||
* The location within one of the memory pools passed in the Request.
|
||||
*/
|
||||
DataLocation location;
|
||||
|
||||
/**
|
||||
* Number of subsequent elements that belong to the dimensions vector.
|
||||
*/
|
||||
uint32_t numberOfDimensions;
|
||||
};
|
||||
|
||||
/**
|
||||
* packetInformation is the first element of the packet and describes the
|
||||
* remainder of the packet.
|
||||
*/
|
||||
PacketInformation packetInformation;
|
||||
|
||||
/**
|
||||
* Information for each input operand.
|
||||
*/
|
||||
OperandInformation inputOperandInformation;
|
||||
|
||||
/**
|
||||
* Element of the dimensions vector.
|
||||
*/
|
||||
uint32_t inputOperandDimensionValue;
|
||||
|
||||
/**
|
||||
* Information for each output operand.
|
||||
*/
|
||||
OperandInformation outputOperandInformation;
|
||||
|
||||
/**
|
||||
* Element of the dimensions vector.
|
||||
*/
|
||||
uint32_t outputOperandDimensionValue;
|
||||
|
||||
/**
|
||||
* Unique identifier for a pool.
|
||||
*
|
||||
* A {@link @1.0::Request} passes across one or more pools of shared memory
|
||||
* for the inputs and outputs of an execution. However, these memory pools
|
||||
* are not able to be sent across FastMessageQueue directly. Instead, the
|
||||
* producing side of the FMQ represents each different pool with a unique
|
||||
* identifier, and sends this identifier across the FMQ. Whenever the
|
||||
* consuming side of the FMQ needs the memory corresponding to this unique
|
||||
* identifier, it can pass the identifier to
|
||||
* {@link IBurstCallback::getMemories} to retreive the memory. Although this
|
||||
* HIDL Binder call is expensive compared to communication across FMQ, it is
|
||||
* only needed in the cases when the consumer does not recognize the unique
|
||||
* identifier.
|
||||
*/
|
||||
int32_t poolIdentifier;
|
||||
|
||||
/**
|
||||
* Specifies whether or not to measure duration of the execution. The
|
||||
* duration runs from the time the driver dequeues the request from a
|
||||
* FastMessageQueue to the time the driver enqueues results to a
|
||||
* FastMessageQueue.
|
||||
*/
|
||||
MeasureTiming measureTiming;
|
||||
};
|
||||
|
||||
/**
|
||||
* FmqResultDatum is a single element of a serialized representation of the
|
||||
* values returned from an execution ({@link @1.0::ErrorStatus},
|
||||
* vec<{@link OutputShape}>, and {@link Timing}) which is returned via
|
||||
* FastMessageQueue.
|
||||
*
|
||||
* The serialized representation for a particular execution is referred to later
|
||||
* in these descriptions as a 'packet'.
|
||||
*
|
||||
* FastMessageQueue can only pass HIDL-defined types that do not involve nested
|
||||
* buffers, handles, or interfaces.
|
||||
*
|
||||
* The execution return values ({@link @1.0::ErrorStatus} and
|
||||
* vec<{@link OutputShape}>) are serialized as follows:
|
||||
* 1) 'packetInformation'
|
||||
* 2) For each returned operand:
|
||||
* 2.1) 'operandInformation'
|
||||
* 2.2) For each dimension element of the operand:
|
||||
* 2.2.1) 'operandDimensionValue'
|
||||
* 3) 'executionTiming'
|
||||
*/
|
||||
safe_union FmqResultDatum {
|
||||
/**
|
||||
* Type to describe the high-level layout of the packet.
|
||||
*/
|
||||
struct PacketInformation {
|
||||
/**
|
||||
* How many elements the packet contains, including the
|
||||
* "packetInformation" datum.
|
||||
*/
|
||||
uint32_t packetSize;
|
||||
|
||||
/**
|
||||
* Status of the execution.
|
||||
*/
|
||||
ErrorStatus errorStatus;
|
||||
|
||||
/**
|
||||
* Number of returned operands.
|
||||
*/
|
||||
uint32_t numberOfOperands;
|
||||
};
|
||||
|
||||
/**
|
||||
* Type representing the information for each operand.
|
||||
*/
|
||||
struct OperandInformation {
|
||||
/**
|
||||
* Indicates whether the operand's output buffer is large enough to
|
||||
* store the operand's result data.
|
||||
*/
|
||||
bool isSufficient;
|
||||
|
||||
/**
|
||||
* Number of subsequent elements that belong to the dimensions vector.
|
||||
*/
|
||||
uint32_t numberOfDimensions;
|
||||
};
|
||||
|
||||
/**
|
||||
* packetInformation is the first element of the packet and describes the
|
||||
* remainder of the packet. It additionally includes the status of the
|
||||
* execution.
|
||||
*/
|
||||
PacketInformation packetInformation;
|
||||
|
||||
/**
|
||||
* Information for each returned operand.
|
||||
*/
|
||||
OperandInformation operandInformation;
|
||||
|
||||
/**
|
||||
* Element of the dimensions vector.
|
||||
*/
|
||||
uint32_t operandDimensionValue;
|
||||
|
||||
/**
|
||||
* Duration of execution. Unless measurement was requested and execution
|
||||
* succeeds, all times must be reported as UINT64_MAX. A driver may choose
|
||||
* to report any time as UINT64_MAX, indicating that measurement is not
|
||||
* available.
|
||||
*/
|
||||
Timing executionTiming;
|
||||
};
|
||||
|
||||
/**
|
||||
* Information about an extension.
|
||||
*/
|
||||
struct Extension {
|
||||
/**
|
||||
* The extension name.
|
||||
*
|
||||
* The name must consist of lowercase latin letters, numbers, periods, and
|
||||
* underscore signs. The name must contain at least one period.
|
||||
*
|
||||
* The name must start with the reverse domain name of the vendor.
|
||||
*
|
||||
* Example: com.google.test_extension
|
||||
*/
|
||||
string name;
|
||||
|
||||
/**
|
||||
* Information about an extension operand type.
|
||||
*/
|
||||
struct OperandTypeInformation {
|
||||
/**
|
||||
* The extension operand type.
|
||||
*/
|
||||
uint16_t type;
|
||||
|
||||
/**
|
||||
* Indicates whether the extension operand type represents a tensor or
|
||||
* a scalar.
|
||||
*/
|
||||
bool isTensor;
|
||||
|
||||
/**
|
||||
* The byte size of the operand (if scalar) or of a single element (if
|
||||
* tensor).
|
||||
*/
|
||||
uint32_t byteSize;
|
||||
};
|
||||
|
||||
/**
|
||||
* Information about operand types defined by the extension.
|
||||
*/
|
||||
vec<OperandTypeInformation> operandTypes;
|
||||
};
|
||||
Reference in New Issue
Block a user