Add NNAPI specification and infrastructure for FL7. am: 2edfc467f1
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1858468 Change-Id: I74c7908ce69fef43a56985897b37869da4ea0743
This commit is contained in:
commit
0ca4f1a02e
6 changed files with 88 additions and 4 deletions
|
@ -405,7 +405,7 @@
|
|||
</hal>
|
||||
<hal format="aidl" optional="true">
|
||||
<name>android.hardware.neuralnetworks</name>
|
||||
<version>1-2</version>
|
||||
<version>1-3</version>
|
||||
<interface>
|
||||
<name>IDevice</name>
|
||||
<regex-instance>.*</regex-instance>
|
||||
|
|
|
@ -138,4 +138,6 @@ enum OperationType {
|
|||
RANK = 101,
|
||||
BATCH_MATMUL = 102,
|
||||
PACK = 103,
|
||||
MIRROR_PAD = 104,
|
||||
REVERSE = 105,
|
||||
}
|
||||
|
|
|
@ -4318,6 +4318,8 @@ enum OperationType {
|
|||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT16}
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM} (since NNAPI feature level 7)
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} (since NNAPI feature level 7)
|
||||
*
|
||||
* Supported tensor rank: from 1.
|
||||
*
|
||||
|
@ -4326,6 +4328,9 @@ enum OperationType {
|
|||
*
|
||||
* Outputs:
|
||||
* * 0: The output tensor of same shape as input0.
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} and
|
||||
* {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} tensor,
|
||||
* the scale and zeroPoint can be different from inputs' scale and zeroPoint.
|
||||
*/
|
||||
RSQRT = 83,
|
||||
|
||||
|
@ -5322,4 +5327,68 @@ enum OperationType {
|
|||
* * 0: The packed tensor.
|
||||
*/
|
||||
PACK = 103,
|
||||
|
||||
/**
|
||||
* Pads a tensor with mirrored values.
|
||||
*
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT16}
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED}
|
||||
* * {@link OperandType::TENSOR_INT32}
|
||||
*
|
||||
* Supported tensor rank: from 1.
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: An n-D tensor, specifying the tensor to be padded.
|
||||
* * 1: A 2-D tensor of {@link OperandType::TENSOR_INT32}, the paddings
|
||||
* for each spatial dimension of the input tensor. The shape of the
|
||||
* tensor must be {rank(input0), 2}.
|
||||
* padding[i, 0] specifies the number of elements to be padded in the
|
||||
* front of dimension i.
|
||||
* padding[i, 1] specifies the number of elements to be padded after the
|
||||
* end of dimension i.
|
||||
* * 2: An {@link OperandType::INT32} scalar, specifying the mode.
|
||||
* Options are 0:REFLECT and 1:SYMMETRIC.
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: A tensor of the same {@link OperandType} as input0. The
|
||||
* output tensor has the same rank as input0, and each
|
||||
* dimension of the output tensor has the same size as the
|
||||
* corresponding dimension of the input tensor plus the size
|
||||
* of the padding:
|
||||
* output0.dimension[i] =
|
||||
* padding[i, 0] + input0.dimension[i] + padding[i, 1]
|
||||
* For a {@link OperandType::TENSOR_QUANT8_ASYMM} and
|
||||
* {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} tensor,
|
||||
* the scale and zeroPoint must be the same as input0.
|
||||
*/
|
||||
MIRROR_PAD = 104,
|
||||
|
||||
/**
|
||||
* Reverses a specified dimension of a tensor.
|
||||
*
|
||||
* Supported tensor {@link OperandType}:
|
||||
* * {@link OperandType::TENSOR_FLOAT16}
|
||||
* * {@link OperandType::TENSOR_FLOAT32}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM}
|
||||
* * {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED}
|
||||
* * {@link OperandType::TENSOR_INT32}
|
||||
*
|
||||
* Supported tensor rank: up to 8.
|
||||
*
|
||||
* Inputs:
|
||||
* * 0: Input tensor of rank n.
|
||||
* * 1: Axis tensor of type {@link OperandType::TENSOR_INT32} and shape [1],
|
||||
* specifying which dimension of the input tensor is to be reversed. The dimension
|
||||
* must be in the range [0, n).
|
||||
*
|
||||
* Outputs:
|
||||
* * 0: The reversed tensor.
|
||||
* For {@link OperandType::TENSOR_QUANT8_ASYMM} and
|
||||
* {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} tensors,
|
||||
* the scales and zeroPoint must be the same as input0.
|
||||
*/
|
||||
REVERSE = 105,
|
||||
}
|
||||
|
|
|
@ -56,13 +56,21 @@ cc_library_static {
|
|||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "neuralnetworks_utils_hal_aidl",
|
||||
name: "neuralnetworks_utils_hal_aidl_v2",
|
||||
defaults: ["neuralnetworks_utils_hal_aidl_defaults"],
|
||||
shared_libs: [
|
||||
"android.hardware.neuralnetworks-V2-ndk",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "neuralnetworks_utils_hal_aidl",
|
||||
defaults: ["neuralnetworks_utils_hal_aidl_defaults"],
|
||||
shared_libs: [
|
||||
"android.hardware.neuralnetworks-V3-ndk",
|
||||
],
|
||||
}
|
||||
|
||||
// A cc_defaults that includes the latest non-experimental AIDL utilities and other AIDL libraries
|
||||
// that are commonly used together. Modules that always depend on the latest non-experimental
|
||||
// AIDL features can include this cc_defaults to avoid managing dependency versions explicitly.
|
||||
|
@ -71,7 +79,7 @@ cc_defaults {
|
|||
static_libs: [
|
||||
"android.hardware.common-V2-ndk",
|
||||
"android.hardware.graphics.common-V2-ndk",
|
||||
"android.hardware.neuralnetworks-V2-ndk",
|
||||
"android.hardware.neuralnetworks-V3-ndk",
|
||||
"neuralnetworks_utils_hal_aidl",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ constexpr std::optional<nn::Version> aidlVersionToCanonicalVersion(int aidlVersi
|
|||
return nn::kVersionFeatureLevel5;
|
||||
case 2:
|
||||
return nn::kVersionFeatureLevel6;
|
||||
case 3:
|
||||
return nn::kVersionFeatureLevel7;
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
@ -159,6 +159,8 @@ std::string printDeviceTest(const testing::TestParamInfo<nn::Version>& info) {
|
|||
return "v1";
|
||||
case nn::Version::Level::FEATURE_LEVEL_6:
|
||||
return "v2";
|
||||
case nn::Version::Level::FEATURE_LEVEL_7:
|
||||
return "v3";
|
||||
default:
|
||||
LOG(FATAL) << "Invalid AIDL version: " << version;
|
||||
return "invalid";
|
||||
|
@ -893,7 +895,8 @@ TEST_P(DeviceTest, allocateDeadObject) {
|
|||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(TestDevice, DeviceTest,
|
||||
::testing::Values(nn::kVersionFeatureLevel5, nn::kVersionFeatureLevel6),
|
||||
::testing::Values(nn::kVersionFeatureLevel5, nn::kVersionFeatureLevel6,
|
||||
nn::kVersionFeatureLevel7),
|
||||
printDeviceTest);
|
||||
|
||||
} // namespace aidl::android::hardware::neuralnetworks::utils
|
||||
|
|
Loading…
Reference in a new issue