diff options
author | Michael Butler <butlermichael@google.com> | 2020-11-01 23:47:40 -0800 |
---|---|---|
committer | Michael Butler <butlermichael@google.com> | 2020-11-05 09:39:27 -0800 |
commit | 7c7b88261d643654ec5dc5b5567bbb60867e6b89 (patch) | |
tree | 91b95563fd10da4d7ba03fcda42fc6b111f90388 | |
parent | 67d7e29ad3430e716a530799b3fb23ead678601e (diff) | |
download | ml-7c7b88261d643654ec5dc5b5567bbb60867e6b89.tar.gz |
Update operation validation from HalVersion to Version
Bug: N/A
Test: mma
Test: NeuralNetworksTest_static
Change-Id: Ia1a10d9ee272a9c2c84a8f284df064c309e42a77
Merged-In: Ia1a10d9ee272a9c2c84a8f284df064c309e42a77
(cherry picked from commit 1ff99066e4f0fa451c03f6236f5de987c6ae064b)
65 files changed, 258 insertions, 243 deletions
diff --git a/nn/common/OperationsUtils.cpp b/nn/common/OperationsUtils.cpp index 9f2af2269..d65566f96 100644 --- a/nn/common/OperationsUtils.cpp +++ b/nn/common/OperationsUtils.cpp @@ -86,9 +86,8 @@ bool validateOutputTypes(const IOperationValidationContext* context, [context](uint32_t index) { return context->getOutputType(index); }); } -bool validateHalVersion(const IOperationValidationContext* context, - HalVersion minSupportedHalVersion) { - if (context->getHalVersion() < minSupportedHalVersion) { +bool validateVersion(const IOperationValidationContext* context, Version minSupportedVersion) { + if (context->getVersion() < minSupportedVersion) { std::ostringstream message; message << "Operation " << context->getOperationName() << " with inputs {"; for (uint32_t i = 0, n = context->getNumInputs(); i < n; ++i) { @@ -104,8 +103,8 @@ bool validateHalVersion(const IOperationValidationContext* context, } message << context->getOutputType(i); } - message << "} is only supported since " << minSupportedHalVersion << " (validating using " - << context->getHalVersion() << ")"; + message << "} is only supported since " << minSupportedVersion << " (validating using " + << context->getVersion() << ")"; NN_RET_CHECK_FAIL() << message.str(); } return true; diff --git a/nn/common/Utils.cpp b/nn/common/Utils.cpp index 398da5508..da4dbc87f 100644 --- a/nn/common/Utils.cpp +++ b/nn/common/Utils.cpp @@ -192,6 +192,23 @@ EntryType tableLookup(const EntryType (&table)[entryCount], } } +static Version convert(HalVersion halVersion) { + switch (halVersion) { + case HalVersion::UNKNOWN: + break; + case HalVersion::V1_0: + return Version::ANDROID_OC_MR1; + case HalVersion::V1_1: + return Version::ANDROID_P; + case HalVersion::V1_2: + return Version::ANDROID_Q; + case HalVersion::V1_3: + return Version::ANDROID_R; + } + LOG(FATAL) << "Cannot convert " << halVersion; + return {}; +} + class OperationValidationContext : public IOperationValidationContext { DISALLOW_IMPLICIT_CONSTRUCTORS(OperationValidationContext); @@ -206,10 +223,10 @@ class OperationValidationContext : public IOperationValidationContext { outputCount(outputCount), outputIndexes(outputIndexes), operands(operands), - halVersion(halVersion) {} + version(convert(halVersion)) {} const char* getOperationName() const override; - HalVersion getHalVersion() const override; + Version getVersion() const override; uint32_t getNumInputs() const override; OperandType getInputType(uint32_t index) const override; @@ -230,15 +247,15 @@ class OperationValidationContext : public IOperationValidationContext { uint32_t outputCount; const uint32_t* outputIndexes; const Operand* operands; - HalVersion halVersion; + Version version; }; const char* OperationValidationContext::getOperationName() const { return operationName; } -HalVersion OperationValidationContext::getHalVersion() const { - return halVersion; +Version OperationValidationContext::getVersion() const { + return version; } const Operand* OperationValidationContext::getInputOperand(uint32_t index) const { diff --git a/nn/common/Validation.cpp b/nn/common/Validation.cpp index 68f778d22..e49f073f2 100644 --- a/nn/common/Validation.cpp +++ b/nn/common/Validation.cpp @@ -1181,7 +1181,7 @@ class OperationValidationContext : public IOperationValidationContext { public: OperationValidationContext(const char* operationName, const std::vector<uint32_t>& inputIndexes, const std::vector<uint32_t>& outputIndexes, - const std::vector<Operand>& operands, HalVersion version) + const std::vector<Operand>& operands, Version version) : operationName(operationName), inputIndexes(inputIndexes), outputIndexes(outputIndexes), @@ -1189,7 +1189,7 @@ class OperationValidationContext : public IOperationValidationContext { version(version) {} const char* getOperationName() const override; - HalVersion getHalVersion() const override; + Version getVersion() const override; uint32_t getNumInputs() const override; OperandType getInputType(uint32_t index) const override; @@ -1208,14 +1208,14 @@ class OperationValidationContext : public IOperationValidationContext { const std::vector<uint32_t>& inputIndexes; const std::vector<uint32_t>& outputIndexes; const std::vector<Operand>& operands; - HalVersion version; + Version version; }; const char* OperationValidationContext::getOperationName() const { return operationName; } -HalVersion OperationValidationContext::getHalVersion() const { +Version OperationValidationContext::getVersion() const { return version; } @@ -2521,18 +2521,16 @@ Result<Version> validateOperationImpl(const Operation& operation, NN_VALIDATE(operationRegistration->validate != nullptr) << "Incomplete operation registration: " << opType; - constexpr HalVersion kHalVersions[] = {HalVersion::V1_0, HalVersion::V1_1, - HalVersion::V1_2, HalVersion::V1_3}; constexpr Version kVersions[] = {Version::ANDROID_OC_MR1, Version::ANDROID_P, - Version::ANDROID_Q, Version::ANDROID_R}; - static_assert(std::size(kHalVersions) == std::size(kVersions)); + Version::ANDROID_Q, Version::ANDROID_R, + Version::CURRENT_RUNTIME}; - for (size_t i = 0; i < std::size(kHalVersions); ++i) { + for (const auto version : kVersions) { OperationValidationContext context(operationRegistration->name, inputIndexes, - outputIndexes, operands, kHalVersions[i]); + outputIndexes, operands, version); auto valid = operationRegistration->validate(&context); if (valid) { - return kVersions[i]; + return version; } } diff --git a/nn/common/include/OperationsUtils.h b/nn/common/include/OperationsUtils.h index 492583f24..676bbb34a 100644 --- a/nn/common/include/OperationsUtils.h +++ b/nn/common/include/OperationsUtils.h @@ -59,21 +59,18 @@ class IOperationValidationContext { virtual const char* getOperationName() const = 0; - // The HAL version of the environment in which the operation is to be - // executed. + // The version of the environment in which the operation is to be executed. // - // Operation validation logic needs to handle all HAL versions to support - // the following use cases (assume in these examples that the latest HAL - // version is V1_2): - // 1. Our runtime wants to distribute work to a driver implementing an older - // HAL version and calls, for example, - // compliantWithV1_0(const V1_2::Model&). - // 2. A driver implements an older HAL version and delegates model - // validation to, for example, validateModel(const V1_0::Model&). + // Operation validation logic needs to handle all versions to support the following use cases + // (assume in these examples that the latest version is Version::ANDROID_Q): + // 1. Our runtime wants to distribute work to a driver implementing an older version and calls, + // for example, compliantWithV1_0(const V1_2::Model&). + // 2. A driver implements an older version and delegates model validation to, for example, + // validateModel(const V1_0::Model&). // - // If getHalVersion() returns HalVersion::V1_0 and the operation - // is only supported since HalVersion::V1_1, validation will fail. - virtual HalVersion getHalVersion() const = 0; + // If getVersion() returns Version::ANDROID_OC_MR1 and the operation is only supported since + // Version::ANDROID_P, validation will fail. + virtual Version getVersion() const = 0; virtual uint32_t getNumInputs() const = 0; virtual OperandType getInputType(uint32_t index) const = 0; @@ -133,8 +130,7 @@ bool validateOutputTypes(const IOperationValidationContext* context, // Verifies that the HAL version specified in the context is greater or equal // than the minimal supported HAL version. -bool validateHalVersion(const IOperationValidationContext* context, - HalVersion minSupportedHalVersion); +bool validateVersion(const IOperationValidationContext* context, Version minSupportedVersion); // Verifies that the two shapes are the same. bool SameShape(const Shape& in1, const Shape& in2); diff --git a/nn/common/operations/Activation.cpp b/nn/common/operations/Activation.cpp index c0a1934d7..e3d848799 100644 --- a/nn/common/operations/Activation.cpp +++ b/nn/common/operations/Activation.cpp @@ -358,17 +358,17 @@ bool validate(OperationType opType, const IOperationValidationContext* context) NN_RET_CHECK_EQ(context->getNumOutputs(), kNumOutputs); auto inputType = context->getInputType(kInputTensor); if (inputType == OperandType::TENSOR_FLOAT32) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); } else if (inputType == OperandType::TENSOR_FLOAT16) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM) { if (opType == OperationType::TANH) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); } } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } else { NN_RET_CHECK_FAIL() << "Unsupported tensor type for operation " << opType; } @@ -386,7 +386,7 @@ bool validateHardSwish(const IOperationValidationContext* context) { if (inputType == OperandType::TENSOR_FLOAT16 || inputType == OperandType::TENSOR_FLOAT32 || inputType == OperandType::TENSOR_QUANT8_ASYMM || inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } else { NN_RET_CHECK_FAIL() << "Unsupported tensor type for operation ELU"; } diff --git a/nn/common/operations/ArgMinMax.cpp b/nn/common/operations/ArgMinMax.cpp index 2ee413c7e..b50895047 100644 --- a/nn/common/operations/ArgMinMax.cpp +++ b/nn/common/operations/ArgMinMax.cpp @@ -20,7 +20,6 @@ #include "CpuOperationUtils.h" #include "Operations.h" - #include "Tracing.h" namespace android { diff --git a/nn/common/operations/BidirectionalSequenceRNN.cpp b/nn/common/operations/BidirectionalSequenceRNN.cpp index adacea0c6..f6b4c301c 100644 --- a/nn/common/operations/BidirectionalSequenceRNN.cpp +++ b/nn/common/operations/BidirectionalSequenceRNN.cpp @@ -335,11 +335,11 @@ bool validate(const IOperationValidationContext* context) { std::vector<OperandType> outExpectedTypes(numOutputs, inputType); NN_RET_CHECK(validateOutputTypes(context, outExpectedTypes)); - HalVersion minSupportedHalVersion = HalVersion::V1_2; + Version minSupportedVersion = Version::ANDROID_Q; if (numOutputs == kNumOutputsWithState || numOutputs == kNumOutputsMergedWithState) { - minSupportedHalVersion = HalVersion::V1_3; + minSupportedVersion = Version::ANDROID_R; } - return validateHalVersion(context, minSupportedHalVersion); + return validateVersion(context, minSupportedVersion); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/Broadcast.cpp b/nn/common/operations/Broadcast.cpp index cf75f3a87..ce1320fb5 100644 --- a/nn/common/operations/Broadcast.cpp +++ b/nn/common/operations/Broadcast.cpp @@ -434,19 +434,19 @@ bool divFloat16(const _Float16* in1, const Shape& shape1, const _Float16* in2, c } // namespace bool validate(OperationType opType, const IOperationValidationContext* context) { - const HalVersion opIntroducedAt = (opType == OperationType::DIV || opType == OperationType::SUB) - ? HalVersion::V1_1 - : HalVersion::V1_0; + const Version opIntroducedAt = (opType == OperationType::DIV || opType == OperationType::SUB) + ? Version::ANDROID_P + : Version::ANDROID_OC_MR1; NN_RET_CHECK_EQ(context->getNumInputs(), kNumInputs); NN_RET_CHECK_EQ(context->getNumOutputs(), kNumOutputs); auto inputType = context->getInputType(kInputTensor1); if (inputType == OperandType::TENSOR_FLOAT32) { - NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_0, opIntroducedAt))); + NN_RET_CHECK(validateVersion(context, std::max(Version::ANDROID_OC_MR1, opIntroducedAt))); } else if (inputType == OperandType::TENSOR_FLOAT16) { - NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_2, opIntroducedAt))); + NN_RET_CHECK(validateVersion(context, std::max(Version::ANDROID_Q, opIntroducedAt))); } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM) { if (opType == OperationType::SUB) { - NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_2, opIntroducedAt))); + NN_RET_CHECK(validateVersion(context, std::max(Version::ANDROID_Q, opIntroducedAt))); } else if (opType == OperationType::DIV) { NN_RET_CHECK_FAIL() << "Unsupported tensor type for operation DIV"; } else if (opType == OperationType::MUL) { @@ -454,13 +454,15 @@ bool validate(OperationType opType, const IOperationValidationContext* context) Shape input1 = context->getInputShape(kInputTensor1); Shape input2 = context->getInputShape(kInputTensor2); NN_RET_CHECK_GT(output.scale, input1.scale * input2.scale); - NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_0, opIntroducedAt))); + NN_RET_CHECK( + validateVersion(context, std::max(Version::ANDROID_OC_MR1, opIntroducedAt))); } else { - NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_0, opIntroducedAt))); + NN_RET_CHECK( + validateVersion(context, std::max(Version::ANDROID_OC_MR1, opIntroducedAt))); } } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED || inputType == OperandType::TENSOR_INT32) { - NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_3, opIntroducedAt))); + NN_RET_CHECK(validateVersion(context, std::max(Version::ANDROID_R, opIntroducedAt))); } else { NN_RET_CHECK_FAIL() << "Unsupported tensor type for operation " << opType; } diff --git a/nn/common/operations/ChannelShuffle.cpp b/nn/common/operations/ChannelShuffle.cpp index 779a8d811..59726fac2 100644 --- a/nn/common/operations/ChannelShuffle.cpp +++ b/nn/common/operations/ChannelShuffle.cpp @@ -73,9 +73,9 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(validateInputTypes(context, {inputType, OperandType::INT32, OperandType::INT32})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } else { - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } } diff --git a/nn/common/operations/Comparisons.cpp b/nn/common/operations/Comparisons.cpp index 50ed806a0..8fdf72c59 100644 --- a/nn/common/operations/Comparisons.cpp +++ b/nn/common/operations/Comparisons.cpp @@ -136,9 +136,9 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(validateInputTypes(context, {inputType, inputType})); NN_RET_CHECK(validateOutputTypes(context, {OperandType::TENSOR_BOOL8})); if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } else { - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } } diff --git a/nn/common/operations/Concatenation.cpp b/nn/common/operations/Concatenation.cpp index 6de5baded..cadfd0f65 100644 --- a/nn/common/operations/Concatenation.cpp +++ b/nn/common/operations/Concatenation.cpp @@ -141,17 +141,17 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK_EQ(context->getNumOutputs(), kNumOutputs); const OperandType inputType = context->getInputType(0); if (inputType == OperandType::TENSOR_FLOAT32 || inputType == OperandType::TENSOR_QUANT8_ASYMM) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); } else if (inputType == OperandType::TENSOR_FLOAT16) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } else { NN_RET_CHECK_FAIL() << "Unsupported tensor type for operation " << kOperationName; } std::vector<OperandType> inExpectedTypes(inputCount - 1, inputType); inExpectedTypes.push_back(OperandType::INT32); - if (context->getHalVersion() < HalVersion::V1_2 && + if (context->getVersion() < Version::ANDROID_Q && inputType == OperandType::TENSOR_QUANT8_ASYMM) { const Shape& output = context->getOutputShape(kOutputTensor); for (uint32_t i = 0; i < inputCount - 1; ++i) { diff --git a/nn/common/operations/Conv2D.cpp b/nn/common/operations/Conv2D.cpp index 5b7d8d0de..5a5e33764 100644 --- a/nn/common/operations/Conv2D.cpp +++ b/nn/common/operations/Conv2D.cpp @@ -613,13 +613,13 @@ bool validate(const IOperationValidationContext* context) { } if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } else if (inputType == OperandType::TENSOR_FLOAT16 || filterType == OperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL || withLayout || withDilation || !meetsQuantizedScaleConstraintBeforeV1_2) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); } return validateInputTypes(context, inExpectedTypes) && validateOutputTypes(context, {inputType}); diff --git a/nn/common/operations/DepthwiseConv2D.cpp b/nn/common/operations/DepthwiseConv2D.cpp index 47bf0104f..611e38d63 100644 --- a/nn/common/operations/DepthwiseConv2D.cpp +++ b/nn/common/operations/DepthwiseConv2D.cpp @@ -496,13 +496,13 @@ bool validate(const IOperationValidationContext* context) { } if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } else if (inputType == OperandType::TENSOR_FLOAT16 || filterType == OperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL || withLayout || withDilation || !meetsQuantizedScaleConstraintBeforeV1_2) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); } return validateInputTypes(context, inExpectedTypes) && validateOutputTypes(context, {inputType}); diff --git a/nn/common/operations/Dequantize.cpp b/nn/common/operations/Dequantize.cpp index 7b8114347..f155eb286 100644 --- a/nn/common/operations/Dequantize.cpp +++ b/nn/common/operations/Dequantize.cpp @@ -89,7 +89,7 @@ bool validate(const IOperationValidationContext* context) { if (inputType == OperandType::TENSOR_QUANT8_ASYMM && outputType == OperandType::TENSOR_FLOAT32) { - return validateHalVersion(context, HalVersion::V1_0); + return validateVersion(context, Version::ANDROID_OC_MR1); } NN_RET_CHECK(inputType == OperandType::TENSOR_QUANT8_ASYMM || @@ -100,7 +100,7 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(outputType == OperandType::TENSOR_FLOAT16 || outputType == OperandType::TENSOR_FLOAT32) << "Unsupported output operand type for DEQUANTIZE op: " << outputType; - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/Elementwise.cpp b/nn/common/operations/Elementwise.cpp index 3ddae9096..a0cd78ffe 100644 --- a/nn/common/operations/Elementwise.cpp +++ b/nn/common/operations/Elementwise.cpp @@ -91,7 +91,7 @@ bool validate(const IOperationValidationContext* context) { << "Unsupported tensor type for elementwise operation"; NN_RET_CHECK(validateInputTypes(context, {inputType})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool validateAbs(const IOperationValidationContext* context) { @@ -103,8 +103,8 @@ bool validateAbs(const IOperationValidationContext* context) { << "Unsupported tensor type for operation ABS"; NN_RET_CHECK(validateInputTypes(context, {inputType})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); - return validateHalVersion(context, (inputType == OperandType::TENSOR_INT32 ? HalVersion::V1_3 - : HalVersion::V1_2)); + return validateVersion(context, (inputType == OperandType::TENSOR_INT32 ? Version::ANDROID_R + : Version::ANDROID_Q)); } bool validateFloor(const IOperationValidationContext* context) { @@ -123,9 +123,9 @@ bool validateFloor(const IOperationValidationContext* context) { NN_RET_CHECK_LE(getNumberOfDimensions(input), 4); } - return validateHalVersion( - context, - (inputType == OperandType::TENSOR_FLOAT16 ? HalVersion::V1_2 : HalVersion::V1_0)); + return validateVersion(context, + (inputType == OperandType::TENSOR_FLOAT16 ? Version::ANDROID_Q + : Version::ANDROID_OC_MR1)); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/Elu.cpp b/nn/common/operations/Elu.cpp index dfb221c63..0c72cb383 100644 --- a/nn/common/operations/Elu.cpp +++ b/nn/common/operations/Elu.cpp @@ -57,7 +57,7 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK_EQ(context->getNumOutputs(), kNumOutputs); auto inputType = context->getInputType(kInputTensor); if (inputType == OperandType::TENSOR_FLOAT16 || inputType == OperandType::TENSOR_FLOAT32) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } else { NN_RET_CHECK_FAIL() << "Unsupported tensor type for operation ELU"; } diff --git a/nn/common/operations/EmbeddingLookup.cpp b/nn/common/operations/EmbeddingLookup.cpp index 5ff26e8e0..b967f1ff6 100644 --- a/nn/common/operations/EmbeddingLookup.cpp +++ b/nn/common/operations/EmbeddingLookup.cpp @@ -20,7 +20,6 @@ #include "CpuExecutor.h" #include "Operations.h" - #include "Tracing.h" namespace android { diff --git a/nn/common/operations/EmbeddingLookupTest.cpp b/nn/common/operations/EmbeddingLookupTest.cpp index 10e2e339a..07ba0960c 100644 --- a/nn/common/operations/EmbeddingLookupTest.cpp +++ b/nn/common/operations/EmbeddingLookupTest.cpp @@ -14,13 +14,14 @@ * limitations under the License. */ -#include "EmbeddingLookup.h" - -#include "NeuralNetworksWrapper.h" - #include <gmock/gmock-matchers.h> #include <gtest/gtest.h> +#include <vector> + +#include "EmbeddingLookup.h" +#include "NeuralNetworksWrapper.h" + using ::testing::FloatNear; using ::testing::Matcher; diff --git a/nn/common/operations/Fill.cpp b/nn/common/operations/Fill.cpp index a23362759..f3b470ed5 100644 --- a/nn/common/operations/Fill.cpp +++ b/nn/common/operations/Fill.cpp @@ -77,7 +77,7 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(getValueType(outputType, &valueType)); NN_RET_CHECK(validateInputTypes(context, {OperandType::TENSOR_INT32, valueType})); - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/FullyConnected.cpp b/nn/common/operations/FullyConnected.cpp index 9fcc072ff..7c8c4e304 100644 --- a/nn/common/operations/FullyConnected.cpp +++ b/nn/common/operations/FullyConnected.cpp @@ -224,7 +224,7 @@ bool validate(const IOperationValidationContext* context) { std::vector<OperandType> inExpectedTypes; std::vector<OperandType> outExpectedTypes; if (inputType == OperandType::TENSOR_FLOAT32) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); inExpectedTypes = { OperandType::TENSOR_FLOAT32, OperandType::TENSOR_FLOAT32, @@ -232,7 +232,7 @@ bool validate(const IOperationValidationContext* context) { OperandType::INT32, }; } else if (inputType == OperandType::TENSOR_FLOAT16) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); inExpectedTypes = { OperandType::TENSOR_FLOAT16, OperandType::TENSOR_FLOAT16, @@ -249,9 +249,9 @@ bool validate(const IOperationValidationContext* context) { bool meetsQuantizedScaleConstraintBeforeV1_2 = (outputScale > inputScale * weightsScale); if (!meetsQuantizedScaleConstraintBeforeV1_2) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); } inExpectedTypes = { @@ -261,7 +261,7 @@ bool validate(const IOperationValidationContext* context) { OperandType::INT32, }; } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); inExpectedTypes = { OperandType::TENSOR_QUANT8_ASYMM_SIGNED, diff --git a/nn/common/operations/Gather.cpp b/nn/common/operations/Gather.cpp index e73a22eb5..6707b6d94 100644 --- a/nn/common/operations/Gather.cpp +++ b/nn/common/operations/Gather.cpp @@ -73,9 +73,9 @@ bool validate(const IOperationValidationContext* context) { {inputType, OperandType::INT32, OperandType::TENSOR_INT32})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } else { - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } } diff --git a/nn/common/operations/GenerateProposals.cpp b/nn/common/operations/GenerateProposals.cpp index 2ef733e14..edd7cb0db 100644 --- a/nn/common/operations/GenerateProposals.cpp +++ b/nn/common/operations/GenerateProposals.cpp @@ -220,7 +220,7 @@ bool validate(const IOperationValidationContext* context) { } NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes(context, {inputType})); - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { @@ -742,9 +742,9 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes(context, outExpectedTypes)); if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } else { - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } } @@ -1268,9 +1268,9 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes(context, outExpectedTypes)); if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } else { - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } } @@ -1597,7 +1597,7 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes( context, {inputType, inputType, OperandType::TENSOR_INT32, OperandType::TENSOR_INT32})); - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/HashtableLookup.cpp b/nn/common/operations/HashtableLookup.cpp index cfb9d9812..4773a17c0 100644 --- a/nn/common/operations/HashtableLookup.cpp +++ b/nn/common/operations/HashtableLookup.cpp @@ -20,7 +20,6 @@ #include "CpuExecutor.h" #include "Operations.h" - #include "Tracing.h" namespace android { diff --git a/nn/common/operations/HashtableLookupTest.cpp b/nn/common/operations/HashtableLookupTest.cpp index ff62006b8..90103440e 100644 --- a/nn/common/operations/HashtableLookupTest.cpp +++ b/nn/common/operations/HashtableLookupTest.cpp @@ -14,13 +14,14 @@ * limitations under the License. */ -#include "HashtableLookup.h" - -#include "NeuralNetworksWrapper.h" - #include <gmock/gmock-matchers.h> #include <gtest/gtest.h> +#include <vector> + +#include "HashtableLookup.h" +#include "NeuralNetworksWrapper.h" + using ::testing::FloatNear; using ::testing::Matcher; diff --git a/nn/common/operations/HeatmapMaxKeypoint.cpp b/nn/common/operations/HeatmapMaxKeypoint.cpp index a07e1428c..1da7ed07f 100644 --- a/nn/common/operations/HeatmapMaxKeypoint.cpp +++ b/nn/common/operations/HeatmapMaxKeypoint.cpp @@ -230,7 +230,7 @@ bool validate(const IOperationValidationContext* context) { std::vector<OperandType> inExpectedTypes; std::vector<OperandType> outExpectedTypes; auto inputType = context->getInputType(kHeatmapTensor); - auto minSupportedHalVersion = HalVersion::V1_2; + auto minSupportedVersion = Version::ANDROID_Q; if (inputType == OperandType::TENSOR_FLOAT32 || inputType == OperandType::TENSOR_FLOAT16) { inExpectedTypes = {inputType, inputType, OperandType::BOOL}; outExpectedTypes = {inputType, inputType}; @@ -243,14 +243,14 @@ bool validate(const IOperationValidationContext* context) { OperandType::TENSOR_QUANT16_ASYMM, OperandType::BOOL}; outExpectedTypes = {OperandType::TENSOR_QUANT8_ASYMM_SIGNED, OperandType::TENSOR_QUANT16_ASYMM}; - minSupportedHalVersion = HalVersion::V1_3; + minSupportedVersion = Version::ANDROID_R; } else { LOG(ERROR) << "Unsupported input tensor type for operation " << kOperationName; return false; } NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes(context, outExpectedTypes)); - return validateHalVersion(context, minSupportedHalVersion); + return validateVersion(context, minSupportedVersion); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/InstanceNormalization.cpp b/nn/common/operations/InstanceNormalization.cpp index 0ce21d03e..62b7728f8 100644 --- a/nn/common/operations/InstanceNormalization.cpp +++ b/nn/common/operations/InstanceNormalization.cpp @@ -116,7 +116,7 @@ bool validate(const IOperationValidationContext* context) { } NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes(context, {inputType})); - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/L2Normalization.cpp b/nn/common/operations/L2Normalization.cpp index f86ab8011..49cc15dda 100644 --- a/nn/common/operations/L2Normalization.cpp +++ b/nn/common/operations/L2Normalization.cpp @@ -204,19 +204,19 @@ bool validate(const IOperationValidationContext* context) { const OperandType inputType = context->getInputType(kInputTensor); std::vector<OperandType> inExpectedTypes = {inputType}; if (inputType == OperandType::TENSOR_FLOAT16 || inputType == OperandType::TENSOR_QUANT8_ASYMM) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else if (inputType == OperandType::TENSOR_FLOAT32) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } else { NN_RET_CHECK_FAIL() << "Unsupported tensor type for operation " << kOperationName; } if (context->getNumInputs() == kNumInputs) { inExpectedTypes.push_back(OperandType::INT32); - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else if (context->getInputShape(kInputTensor).dimensions.size() != 4) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } const Shape& input = context->getInputShape(kInputTensor); if (hasKnownRank(input)) { diff --git a/nn/common/operations/LSHProjectionTest.cpp b/nn/common/operations/LSHProjectionTest.cpp index 8e27b647a..41823030d 100644 --- a/nn/common/operations/LSHProjectionTest.cpp +++ b/nn/common/operations/LSHProjectionTest.cpp @@ -14,14 +14,15 @@ * limitations under the License. */ -#include "LSHProjection.h" - -#include "NeuralNetworksWrapper.h" - -#include <gmock/gmock.h> #include <gmock/gmock-matchers.h> +#include <gmock/gmock.h> #include <gtest/gtest.h> +#include <vector> + +#include "LSHProjection.h" +#include "NeuralNetworksWrapper.h" + using ::testing::FloatNear; using ::testing::Matcher; diff --git a/nn/common/operations/LSTMTest.cpp b/nn/common/operations/LSTMTest.cpp index 6fbc5d125..46661cff3 100644 --- a/nn/common/operations/LSTMTest.cpp +++ b/nn/common/operations/LSTMTest.cpp @@ -14,14 +14,13 @@ * limitations under the License. */ -#include "LSTM.h" - -#include "NeuralNetworksWrapper.h" +#include <gmock/gmock-matchers.h> +#include <gtest/gtest.h> #include <vector> -#include <gmock/gmock-matchers.h> -#include <gtest/gtest.h> +#include "LSTM.h" +#include "NeuralNetworksWrapper.h" namespace android { namespace nn { diff --git a/nn/common/operations/LayerNormLSTMTest.cpp b/nn/common/operations/LayerNormLSTMTest.cpp index 1cac0df65..a856c5f35 100644 --- a/nn/common/operations/LayerNormLSTMTest.cpp +++ b/nn/common/operations/LayerNormLSTMTest.cpp @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "LSTM.h" - -#include "NeuralNetworksWrapper.h" - #include <android-base/logging.h> #include <gmock/gmock-matchers.h> #include <gtest/gtest.h> + #include <sstream> #include <string> #include <vector> +#include "LSTM.h" +#include "NeuralNetworksWrapper.h" + namespace android { namespace nn { namespace wrapper { diff --git a/nn/common/operations/LocalResponseNormalization.cpp b/nn/common/operations/LocalResponseNormalization.cpp index 26a7a002a..6276168a7 100644 --- a/nn/common/operations/LocalResponseNormalization.cpp +++ b/nn/common/operations/LocalResponseNormalization.cpp @@ -139,14 +139,14 @@ bool validate(const IOperationValidationContext* context) { std::vector<OperandType> inExpectedTypes; std::vector<OperandType> outExpectedTypes; if (inputType == OperandType::TENSOR_FLOAT32) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); inExpectedTypes = { OperandType::TENSOR_FLOAT32, OperandType::INT32, OperandType::FLOAT32, OperandType::FLOAT32, OperandType::FLOAT32, }; outExpectedTypes = {OperandType::TENSOR_FLOAT32}; } else if (inputType == OperandType::TENSOR_FLOAT16) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); inExpectedTypes = { OperandType::TENSOR_FLOAT16, OperandType::INT32, OperandType::FLOAT16, OperandType::FLOAT16, OperandType::FLOAT16, @@ -158,9 +158,9 @@ bool validate(const IOperationValidationContext* context) { if (context->getNumInputs() == kNumInputs) { inExpectedTypes.push_back(OperandType::INT32); - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else if (context->getInputShape(kInputTensor).dimensions.size() != 4) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } const Shape& input = context->getInputShape(kInputTensor); diff --git a/nn/common/operations/LogSoftmax.cpp b/nn/common/operations/LogSoftmax.cpp index fdcccf851..86a882fd5 100644 --- a/nn/common/operations/LogSoftmax.cpp +++ b/nn/common/operations/LogSoftmax.cpp @@ -88,7 +88,7 @@ bool validate(const IOperationValidationContext* context) { } NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes(context, outExpectedTypes)); - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/LogicalAndOr.cpp b/nn/common/operations/LogicalAndOr.cpp index 9d7e5ce19..163aa5432 100644 --- a/nn/common/operations/LogicalAndOr.cpp +++ b/nn/common/operations/LogicalAndOr.cpp @@ -68,7 +68,7 @@ bool validate(const IOperationValidationContext* context) { << "Unsupported tensor type for a logical operation"; NN_RET_CHECK(validateInputTypes(context, {inputType, inputType})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/LogicalNot.cpp b/nn/common/operations/LogicalNot.cpp index c71538854..2f6bb637b 100644 --- a/nn/common/operations/LogicalNot.cpp +++ b/nn/common/operations/LogicalNot.cpp @@ -49,7 +49,7 @@ bool validate(const IOperationValidationContext* context) { << "Unsupported tensor type for LOGICAL_NOT"; NN_RET_CHECK(validateInputTypes(context, {inputType})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/MaximumMinimum.cpp b/nn/common/operations/MaximumMinimum.cpp index 339172fd2..0b27e27eb 100644 --- a/nn/common/operations/MaximumMinimum.cpp +++ b/nn/common/operations/MaximumMinimum.cpp @@ -16,10 +16,11 @@ #define LOG_TAG "Operations" +#include "MaximumMinimum.h" + #include <algorithm> #include <vector> -#include "MaximumMinimum.h" #include "IndexedShapeWrapper.h" #include "OperationsUtils.h" #include "Tracing.h" diff --git a/nn/common/operations/Multinomial.cpp b/nn/common/operations/Multinomial.cpp index 80fb7e880..6521bc715 100644 --- a/nn/common/operations/Multinomial.cpp +++ b/nn/common/operations/Multinomial.cpp @@ -18,19 +18,18 @@ #include "Multinomial.h" +#include <algorithm> +#include <limits> +#include <unsupported/Eigen/CXX11/Tensor> +#include <vector> + #include "CpuExecutor.h" #include "CpuOperationUtils.h" #include "Tracing.h" - #include "guarded_philox_random.h" #include "philox_random.h" #include "simple_philox.h" -#include <algorithm> -#include <limits> -#include <unsupported/Eigen/CXX11/Tensor> -#include <vector> - namespace android { namespace nn { diff --git a/nn/common/operations/Neg.cpp b/nn/common/operations/Neg.cpp index bf2172704..1d042fcbe 100644 --- a/nn/common/operations/Neg.cpp +++ b/nn/common/operations/Neg.cpp @@ -16,12 +16,12 @@ #define LOG_TAG "Operations" +#include <cmath> + #include "OperationResolver.h" #include "OperationsUtils.h" #include "Tracing.h" -#include <cmath> - namespace android { namespace nn { namespace neg { @@ -56,7 +56,7 @@ bool validate(const IOperationValidationContext* context) { << "Unsupported tensor type for operation " << kOperationName; NN_RET_CHECK(validateInputTypes(context, {inputType})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/PRelu.cpp b/nn/common/operations/PRelu.cpp index 7e0c8c371..db2f6d416 100644 --- a/nn/common/operations/PRelu.cpp +++ b/nn/common/operations/PRelu.cpp @@ -16,6 +16,8 @@ #define LOG_TAG "Operations" +#include <tensorflow/lite/kernels/internal/optimized/legacy_optimized_ops.h> + #include <algorithm> #include <vector> @@ -24,8 +26,6 @@ #include "OperationsUtils.h" #include "Tracing.h" -#include <tensorflow/lite/kernels/internal/optimized/legacy_optimized_ops.h> - namespace android { namespace nn { namespace prelu { @@ -107,9 +107,9 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(validateInputTypes(context, {inputType, inputType})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } else { - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } } diff --git a/nn/common/operations/Pooling.cpp b/nn/common/operations/Pooling.cpp index 62594c783..bc6571d79 100644 --- a/nn/common/operations/Pooling.cpp +++ b/nn/common/operations/Pooling.cpp @@ -294,13 +294,13 @@ bool validate(OperationType opType, const IOperationValidationContext* context) auto inputType = context->getInputType(kInputTensor); std::vector<OperandType> inExpectedTypes; if (inputType == OperandType::TENSOR_FLOAT32) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); inExpectedTypes = { inputType, OperandType::INT32, OperandType::INT32, OperandType::INT32, OperandType::INT32, OperandType::INT32, OperandType::INT32, }; } else if (inputType == OperandType::TENSOR_FLOAT16) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); inExpectedTypes = { OperandType::TENSOR_FLOAT16, OperandType::INT32, OperandType::INT32, OperandType::INT32, OperandType::INT32, OperandType::INT32, @@ -308,7 +308,7 @@ bool validate(OperationType opType, const IOperationValidationContext* context) }; } else if (opType != OperationType::L2_POOL_2D && inputType == OperandType::TENSOR_QUANT8_ASYMM) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); inExpectedTypes = { OperandType::TENSOR_QUANT8_ASYMM, OperandType::INT32, @@ -320,7 +320,7 @@ bool validate(OperationType opType, const IOperationValidationContext* context) }; } else if (opType != OperationType::L2_POOL_2D && inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); inExpectedTypes = { OperandType::TENSOR_QUANT8_ASYMM_SIGNED, OperandType::INT32, @@ -341,9 +341,9 @@ bool validate(OperationType opType, const IOperationValidationContext* context) } if (inputCount == 11 || inputCount == 8) { inExpectedTypes.push_back(OperandType::BOOL); - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); } return validateInputTypes(context, inExpectedTypes) && validateOutputTypes(context, {inputType}); diff --git a/nn/common/operations/Pow.cpp b/nn/common/operations/Pow.cpp index 03892a230..2506549eb 100644 --- a/nn/common/operations/Pow.cpp +++ b/nn/common/operations/Pow.cpp @@ -17,12 +17,13 @@ #define LOG_TAG "Operations" #include "Pow.h" -#include "IndexedShapeWrapper.h" -#include "OperationsUtils.h" #include <cmath> #include <vector> +#include "IndexedShapeWrapper.h" +#include "OperationsUtils.h" + namespace android { namespace nn { namespace pow { diff --git a/nn/common/operations/QLSTM.cpp b/nn/common/operations/QLSTM.cpp index 68a9489fc..0812e6661 100644 --- a/nn/common/operations/QLSTM.cpp +++ b/nn/common/operations/QLSTM.cpp @@ -149,7 +149,7 @@ bool validate(const IOperationValidationContext* context) { outExpectedTypes.push_back(OperandType::TENSOR_QUANT8_ASYMM_SIGNED); NN_RET_CHECK(validateOutputTypes(context, outExpectedTypes)); - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/Quantize.cpp b/nn/common/operations/Quantize.cpp index 943a33dcb..c3f4812c2 100644 --- a/nn/common/operations/Quantize.cpp +++ b/nn/common/operations/Quantize.cpp @@ -17,13 +17,13 @@ #include "OperationsUtils.h" #define LOG_TAG "Operations" +#include <algorithm> +#include <cmath> + #include "IndexedShapeWrapper.h" #include "OperationResolver.h" #include "Tracing.h" -#include <algorithm> -#include <cmath> - namespace android { namespace nn { namespace quantize { @@ -77,9 +77,9 @@ bool validate(const IOperationValidationContext* context) { outputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) << "Unsupported output operand type for QUANTIZE op: " << outputType; if (outputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } else { - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } } diff --git a/nn/common/operations/QuantizedLSTM.cpp b/nn/common/operations/QuantizedLSTM.cpp index f07bc0a40..590bdb952 100644 --- a/nn/common/operations/QuantizedLSTM.cpp +++ b/nn/common/operations/QuantizedLSTM.cpp @@ -18,16 +18,16 @@ #include "QuantizedLSTM.h" -#include "CpuExecutor.h" -#include "CpuOperationUtils.h" - -#include "Tracing.h" - #include <public/gemmlowp.h> #include <tensorflow/lite/kernels/internal/reference/legacy_reference_ops.h> + #include <algorithm> #include <vector> +#include "CpuExecutor.h" +#include "CpuOperationUtils.h" +#include "Tracing.h" + namespace android { namespace nn { diff --git a/nn/common/operations/QuantizedLSTMTest.cpp b/nn/common/operations/QuantizedLSTMTest.cpp index 0db5106cb..00b3b56f9 100644 --- a/nn/common/operations/QuantizedLSTMTest.cpp +++ b/nn/common/operations/QuantizedLSTMTest.cpp @@ -14,13 +14,14 @@ * limitations under the License. */ -#include "QuantizedLSTM.h" - -#include "NeuralNetworksWrapper.h" - #include <gmock/gmock-matchers.h> #include <gtest/gtest.h> + #include <iostream> +#include <vector> + +#include "NeuralNetworksWrapper.h" +#include "QuantizedLSTM.h" namespace android { namespace nn { diff --git a/nn/common/operations/RNN.cpp b/nn/common/operations/RNN.cpp index f584f0e1b..bc5a81949 100644 --- a/nn/common/operations/RNN.cpp +++ b/nn/common/operations/RNN.cpp @@ -16,13 +16,12 @@ #define LOG_TAG "Operations" -#include <vector> - #include "RNN.h" +#include <vector> + #include "CpuExecutor.h" #include "CpuOperationUtils.h" - #include "Tracing.h" namespace android { diff --git a/nn/common/operations/RNNTest.cpp b/nn/common/operations/RNNTest.cpp index 66acac7cb..d125586ee 100644 --- a/nn/common/operations/RNNTest.cpp +++ b/nn/common/operations/RNNTest.cpp @@ -14,13 +14,14 @@ * limitations under the License. */ -#include "RNN.h" - -#include "NeuralNetworksWrapper.h" - #include <gmock/gmock-matchers.h> #include <gtest/gtest.h> +#include <vector> + +#include "NeuralNetworksWrapper.h" +#include "RNN.h" + namespace android { namespace nn { namespace wrapper { diff --git a/nn/common/operations/Rank.cpp b/nn/common/operations/Rank.cpp index 8a6931beb..71951d703 100644 --- a/nn/common/operations/Rank.cpp +++ b/nn/common/operations/Rank.cpp @@ -46,7 +46,7 @@ bool validate(const IOperationValidationContext* context) { inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) << "Incorrect input type for a RANK op: " << inputType; NN_RET_CHECK(validateOutputTypes(context, {OperandType::INT32})); - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/Reduce.cpp b/nn/common/operations/Reduce.cpp index c56771cc3..0563a3536 100644 --- a/nn/common/operations/Reduce.cpp +++ b/nn/common/operations/Reduce.cpp @@ -80,7 +80,7 @@ bool validateProdSum(const IOperationValidationContext* context) { if (hasKnownRank(input)) { NN_RET_CHECK_LE(getNumberOfDimensions(input), 4); } - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool validateMaxMin(const IOperationValidationContext* context) { @@ -95,15 +95,15 @@ bool validateMaxMin(const IOperationValidationContext* context) { NN_RET_CHECK( validateInputTypes(context, {inputType, OperandType::TENSOR_INT32, OperandType::BOOL})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); - auto minHalVersion = HalVersion::V1_2; + auto minVersion = Version::ANDROID_Q; if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - minHalVersion = HalVersion::V1_3; + minVersion = Version::ANDROID_R; } const Shape& input = context->getInputShape(kInputTensor); if (hasKnownRank(input)) { NN_RET_CHECK_LE(getNumberOfDimensions(input), 4); } - return validateHalVersion(context, minHalVersion); + return validateVersion(context, minVersion); } bool validateLogical(const IOperationValidationContext* context) { @@ -119,7 +119,7 @@ bool validateLogical(const IOperationValidationContext* context) { if (hasKnownRank(input)) { NN_RET_CHECK_LE(getNumberOfDimensions(input), 4); } - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/ResizeImageOps.cpp b/nn/common/operations/ResizeImageOps.cpp index 90420994c..a1acf187d 100644 --- a/nn/common/operations/ResizeImageOps.cpp +++ b/nn/common/operations/ResizeImageOps.cpp @@ -187,13 +187,13 @@ bool validate(OperationType opType, const IOperationValidationContext* context) inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) << "Unsupported tensor type for operation " << opType; if (inputType == OperandType::TENSOR_FLOAT16 || inputType == OperandType::TENSOR_QUANT8_ASYMM) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } if (scalarType != OperandType::INT32) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); if (inputType == OperandType::TENSOR_FLOAT32) { NN_RET_CHECK(scalarType == OperandType::FLOAT32); } else if (inputType == OperandType::TENSOR_FLOAT16) { @@ -204,15 +204,15 @@ bool validate(OperationType opType, const IOperationValidationContext* context) } } if (numInputs < kNumInputs) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); } else if (numInputs == kNumInputs) { inExpectedTypes.push_back(OperandType::BOOL); - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else { while (inExpectedTypes.size() < numInputs) { inExpectedTypes.push_back(OperandType::BOOL); } - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } return validateInputTypes(context, inExpectedTypes) && validateOutputTypes(context, {inputType}); diff --git a/nn/common/operations/RoiAlign.cpp b/nn/common/operations/RoiAlign.cpp index 01008cc9d..78049b8bb 100644 --- a/nn/common/operations/RoiAlign.cpp +++ b/nn/common/operations/RoiAlign.cpp @@ -16,17 +16,18 @@ #define LOG_TAG "Operations" -#include "CpuOperationUtils.h" -#include "OperationResolver.h" -#include "OperationsUtils.h" -#include "Tracing.h" - #include <tensorflow/lite/kernels/internal/common.h> + #include <algorithm> #include <cfloat> #include <cmath> #include <vector> +#include "CpuOperationUtils.h" +#include "OperationResolver.h" +#include "OperationsUtils.h" +#include "Tracing.h" + namespace android { namespace nn { namespace roi_align { @@ -372,9 +373,9 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes(context, {inputType})); if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); } else { - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } } diff --git a/nn/common/operations/RoiPooling.cpp b/nn/common/operations/RoiPooling.cpp index 373669aab..a011b4ae2 100644 --- a/nn/common/operations/RoiPooling.cpp +++ b/nn/common/operations/RoiPooling.cpp @@ -216,10 +216,10 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes(context, {inputType})); if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - return validateHalVersion(context, HalVersion::V1_3); + return validateVersion(context, Version::ANDROID_R); ; } else { - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } } diff --git a/nn/common/operations/SVDF.cpp b/nn/common/operations/SVDF.cpp index 953e2a84f..59049360c 100644 --- a/nn/common/operations/SVDF.cpp +++ b/nn/common/operations/SVDF.cpp @@ -18,11 +18,11 @@ #include "SVDF.h" -#include "CpuExecutor.h" -#include "CpuOperationUtils.h" - #include <algorithm> #include <vector> + +#include "CpuExecutor.h" +#include "CpuOperationUtils.h" #include "Tracing.h" namespace android { diff --git a/nn/common/operations/SVDFTest.cpp b/nn/common/operations/SVDFTest.cpp index 21f769fc2..09651d7e0 100644 --- a/nn/common/operations/SVDFTest.cpp +++ b/nn/common/operations/SVDFTest.cpp @@ -14,11 +14,13 @@ * limitations under the License. */ -#include "SVDF.h" - #include <gmock/gmock-matchers.h> #include <gtest/gtest.h> + +#include <vector> + #include "NeuralNetworksWrapper.h" +#include "SVDF.h" using ::testing::FloatNear; using ::testing::Matcher; diff --git a/nn/common/operations/Select.cpp b/nn/common/operations/Select.cpp index 91053896d..0b7728ab9 100644 --- a/nn/common/operations/Select.cpp +++ b/nn/common/operations/Select.cpp @@ -78,7 +78,7 @@ bool validate(const IOperationValidationContext* context) { << "Unsupported input operand type for select op: " << inputType; NN_RET_CHECK(validateInputTypes(context, {OperandType::TENSOR_BOOL8, inputType, inputType})); NN_RET_CHECK(validateOutputTypes(context, {inputType})); - return validateHalVersion(context, HalVersion::V1_2); + return validateVersion(context, Version::ANDROID_Q); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/Slice.cpp b/nn/common/operations/Slice.cpp index 1b5a493f7..3cf3c8a33 100644 --- a/nn/common/operations/Slice.cpp +++ b/nn/common/operations/Slice.cpp @@ -16,12 +16,12 @@ #define LOG_TAG "Operations" +#include <vector> + #include "CpuOperationUtils.h" #include "IndexedShapeWrapper.h" #include "OperationResolver.h" -#include <vector> - namespace android { namespace nn { namespace slice { @@ -90,9 +90,9 @@ bool validate(const IOperationValidationContext* context) { inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) << "Unsupported tensor type for operation " << kOperationName; if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } else { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } return validateInputTypes(context, {inputType, OperandType::TENSOR_INT32, OperandType::TENSOR_INT32}) && diff --git a/nn/common/operations/Softmax.cpp b/nn/common/operations/Softmax.cpp index bb85c0b66..a9373957a 100644 --- a/nn/common/operations/Softmax.cpp +++ b/nn/common/operations/Softmax.cpp @@ -233,13 +233,13 @@ bool validate(const IOperationValidationContext* context) { auto inputType = context->getInputType(kInputTensor); std::vector<OperandType> inExpectedTypes; if (inputType == OperandType::TENSOR_FLOAT32 || inputType == OperandType::TENSOR_QUANT8_ASYMM) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_0)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_OC_MR1)); inExpectedTypes = {inputType, OperandType::FLOAT32}; } else if (inputType == OperandType::TENSOR_FLOAT16) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); inExpectedTypes = {inputType, OperandType::FLOAT16}; } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); inExpectedTypes = {inputType, OperandType::FLOAT32}; } else { NN_RET_CHECK_FAIL() << "Unsupported tensor type for operation " << kOperationName; @@ -249,11 +249,11 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK_LE(inputRank, 4); } if (context->getNumInputs() == kNumInputs) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); inExpectedTypes.push_back(OperandType::INT32); } else { if (inputRank != 2 && inputRank != 4 && inputRank != 0) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } } return validateInputTypes(context, inExpectedTypes) && diff --git a/nn/common/operations/Split.cpp b/nn/common/operations/Split.cpp index 1b3916262..441b5a2fa 100644 --- a/nn/common/operations/Split.cpp +++ b/nn/common/operations/Split.cpp @@ -20,7 +20,6 @@ #include "Operations.h" #include "OperationsUtils.h" - #include "Tracing.h" namespace android { diff --git a/nn/common/operations/Squeeze.cpp b/nn/common/operations/Squeeze.cpp index d7345505c..e9640b964 100644 --- a/nn/common/operations/Squeeze.cpp +++ b/nn/common/operations/Squeeze.cpp @@ -45,13 +45,13 @@ bool validate(const IOperationValidationContext* context) { inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) << "Unsupported input operand type for SQUEEZE op: " << inputType; - HalVersion minSupportedHalVersion; + Version minSupportedVersion; if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - minSupportedHalVersion = HalVersion::V1_3; + minSupportedVersion = Version::ANDROID_R; } else if (inputType == OperandType::TENSOR_FLOAT16) { - minSupportedHalVersion = HalVersion::V1_2; + minSupportedVersion = Version::ANDROID_Q; } else { - minSupportedHalVersion = HalVersion::V1_1; + minSupportedVersion = Version::ANDROID_P; } NN_RET_CHECK(validateInputTypes(context, { @@ -63,7 +63,7 @@ bool validate(const IOperationValidationContext* context) { if (hasKnownRank(input)) { NN_RET_CHECK_LE(getNumberOfDimensions(input), 4); } - return validateHalVersion(context, minSupportedHalVersion); + return validateVersion(context, minSupportedVersion); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/StridedSlice.cpp b/nn/common/operations/StridedSlice.cpp index 3bb3a829d..654659ac1 100644 --- a/nn/common/operations/StridedSlice.cpp +++ b/nn/common/operations/StridedSlice.cpp @@ -106,13 +106,13 @@ bool validate(const IOperationValidationContext* context) { inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) << "Unsupported input operand type for STRIDED_SLICE op: " << inputType; - HalVersion minSupportedHalVersion; + Version minSupportedVersion; if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - minSupportedHalVersion = HalVersion::V1_3; + minSupportedVersion = Version::ANDROID_R; } else if (inputType == OperandType::TENSOR_FLOAT16) { - minSupportedHalVersion = HalVersion::V1_2; + minSupportedVersion = Version::ANDROID_Q; } else { - minSupportedHalVersion = HalVersion::V1_1; + minSupportedVersion = Version::ANDROID_P; } NN_RET_CHECK(validateInputTypes(context, { @@ -129,7 +129,7 @@ bool validate(const IOperationValidationContext* context) { if (hasKnownRank(input)) { NN_RET_CHECK_LE(getNumberOfDimensions(input), 4); } - return validateHalVersion(context, minSupportedHalVersion); + return validateVersion(context, minSupportedVersion); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/Tile.cpp b/nn/common/operations/Tile.cpp index af17df1b9..da794a548 100644 --- a/nn/common/operations/Tile.cpp +++ b/nn/common/operations/Tile.cpp @@ -16,10 +16,11 @@ #define LOG_TAG "Operations" +#include "Tile.h" + #include <algorithm> #include <utility> -#include "Tile.h" #include "Tracing.h" namespace android { diff --git a/nn/common/operations/TopK_V2.cpp b/nn/common/operations/TopK_V2.cpp index 9e4ceeda8..d91c8131e 100644 --- a/nn/common/operations/TopK_V2.cpp +++ b/nn/common/operations/TopK_V2.cpp @@ -85,11 +85,11 @@ bool validate(const IOperationValidationContext* context) { << "Unsupported input operand type for select op: " << inputType; NN_RET_CHECK(validateInputTypes(context, {inputType, OperandType::INT32})); NN_RET_CHECK(validateOutputTypes(context, {inputType, OperandType::TENSOR_INT32})); - HalVersion minSupportedHalVersion = HalVersion::V1_2; + Version minSupportedVersion = Version::ANDROID_Q; if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - minSupportedHalVersion = HalVersion::V1_3; + minSupportedVersion = Version::ANDROID_R; } - return validateHalVersion(context, minSupportedHalVersion); + return validateVersion(context, minSupportedVersion); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/Transpose.cpp b/nn/common/operations/Transpose.cpp index 423b3ded6..3bc76f03e 100644 --- a/nn/common/operations/Transpose.cpp +++ b/nn/common/operations/Transpose.cpp @@ -16,14 +16,13 @@ #define LOG_TAG "Operations" +#include <tensorflow/lite/kernels/internal/optimized/legacy_optimized_ops.h> +#include <tensorflow/lite/kernels/internal/reference/reference_ops.h> + #include <vector> #include "CpuOperationUtils.h" #include "OperationResolver.h" - -#include <tensorflow/lite/kernels/internal/optimized/legacy_optimized_ops.h> -#include <tensorflow/lite/kernels/internal/reference/reference_ops.h> - #include "Tracing.h" namespace android { @@ -76,11 +75,11 @@ bool validate(const IOperationValidationContext* context) { const OperandType inputType = context->getInputType(kInputTensor); if (inputType == OperandType::TENSOR_FLOAT32 || inputType == OperandType::TENSOR_QUANT8_ASYMM) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_1)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_P)); } else if (inputType == OperandType::TENSOR_FLOAT16) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_2)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_Q)); } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - NN_RET_CHECK(validateHalVersion(context, HalVersion::V1_3)); + NN_RET_CHECK(validateVersion(context, Version::ANDROID_R)); } else { NN_RET_CHECK_FAIL() << "Unsupported tensor type for operation " << kOperationName; } diff --git a/nn/common/operations/TransposeConv2D.cpp b/nn/common/operations/TransposeConv2D.cpp index 0ee5d044c..78d857a35 100644 --- a/nn/common/operations/TransposeConv2D.cpp +++ b/nn/common/operations/TransposeConv2D.cpp @@ -440,7 +440,7 @@ bool validate(const IOperationValidationContext* context) { const auto inputType = context->getInputType(kInputTensor); const auto filterType = context->getInputType(kFilterTensor); std::vector<OperandType> inExpectedTypes; - HalVersion minSupportedHalVersion = HalVersion::V1_2; + Version minSupportedVersion = Version::ANDROID_Q; if (inputType == OperandType::TENSOR_FLOAT32 || inputType == OperandType::TENSOR_FLOAT16) { inExpectedTypes = {inputType, inputType, inputType}; } else if (inputType == OperandType::TENSOR_QUANT8_ASYMM || @@ -458,7 +458,7 @@ bool validate(const IOperationValidationContext* context) { } inExpectedTypes = {inputType, filterType, OperandType::TENSOR_INT32}; if (inputType == OperandType::TENSOR_QUANT8_ASYMM_SIGNED) { - minSupportedHalVersion = HalVersion::V1_3; + minSupportedVersion = Version::ANDROID_R; } } else { NN_RET_CHECK_FAIL() << "Unsupported input tensor type for operation " << kOperationName; @@ -474,7 +474,7 @@ bool validate(const IOperationValidationContext* context) { OperandType::INT32, OperandType::INT32, OperandType::BOOL}; } inExpectedTypes.insert(inExpectedTypes.end(), argExpectedTypes.begin(), argExpectedTypes.end()); - NN_RET_CHECK(validateHalVersion(context, minSupportedHalVersion)); + NN_RET_CHECK(validateVersion(context, minSupportedVersion)); return validateInputTypes(context, inExpectedTypes) && validateOutputTypes(context, {inputType}); } diff --git a/nn/common/operations/UnidirectionalSequenceLSTM.cpp b/nn/common/operations/UnidirectionalSequenceLSTM.cpp index 9a00e1f01..02da1581f 100644 --- a/nn/common/operations/UnidirectionalSequenceLSTM.cpp +++ b/nn/common/operations/UnidirectionalSequenceLSTM.cpp @@ -156,14 +156,14 @@ bool validate(const IOperationValidationContext* context) { << "Unsupported input operand type for UNIDIRECTIONAL_SEQUENCE_LSTM op: " << inputType; } - HalVersion minHalVersionSupported = HalVersion::V1_2; + Version minVersionSupported = Version::ANDROID_Q; if (context->getNumOutputs() == kNumOutputsWithState) { - minHalVersionSupported = HalVersion::V1_3; + minVersionSupported = Version::ANDROID_R; outExpectedTypes.insert(outExpectedTypes.end(), {inputType, inputType}); } NN_RET_CHECK(validateInputTypes(context, inExpectedTypes)); NN_RET_CHECK(validateOutputTypes(context, outExpectedTypes)); - return validateHalVersion(context, minHalVersionSupported); + return validateVersion(context, minVersionSupported); } bool prepare(IOperationExecutionContext* context) { diff --git a/nn/common/operations/UnidirectionalSequenceRNN.cpp b/nn/common/operations/UnidirectionalSequenceRNN.cpp index aa79739ec..382aa58e3 100644 --- a/nn/common/operations/UnidirectionalSequenceRNN.cpp +++ b/nn/common/operations/UnidirectionalSequenceRNN.cpp @@ -139,13 +139,13 @@ bool validate(const IOperationValidationContext* context) { NN_RET_CHECK(validateInputTypes(context, {inputType, inputType, inputType, inputType, inputType, OperandType::INT32, OperandType::INT32})); std::vector<OperandType> outputTypes = {inputType}; - HalVersion minHalVersionSupported = HalVersion::V1_2; + Version minVersionSupported = Version::ANDROID_Q; if (numOutputs == kNumOutputsWithState) { - minHalVersionSupported = HalVersion::V1_3; + minVersionSupported = Version::ANDROID_R; outputTypes.push_back(inputType); } NN_RET_CHECK(validateOutputTypes(context, outputTypes)); - return validateHalVersion(context, minHalVersionSupported); + return validateVersion(context, minVersionSupported); } bool prepare(IOperationExecutionContext* context) { |