Merge "Update operation validation from HalVersion to Version"
diff --git a/nn/common/OperationsUtils.cpp b/nn/common/OperationsUtils.cpp
index 9f2af22..d65566f 100644
--- a/nn/common/OperationsUtils.cpp
+++ b/nn/common/OperationsUtils.cpp
@@ -86,9 +86,8 @@
             [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 @@
             }
             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 398da55..da4dbc8 100644
--- a/nn/common/Utils.cpp
+++ b/nn/common/Utils.cpp
@@ -192,6 +192,23 @@
     }
 }
 
+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 @@
           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 @@
     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 68f778d..e49f073 100644
--- a/nn/common/Validation.cpp
+++ b/nn/common/Validation.cpp
@@ -1181,7 +1181,7 @@
    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 @@
           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 @@
     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 @@
             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 492583f..676bbb3 100644
--- a/nn/common/include/OperationsUtils.h
+++ b/nn/common/include/OperationsUtils.h
@@ -59,21 +59,18 @@
 
     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 @@
 
 // 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 c0a1934..e3d8487 100644
--- a/nn/common/operations/Activation.cpp
+++ b/nn/common/operations/Activation.cpp
@@ -358,17 +358,17 @@
     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 @@
     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 2ee413c..b508950 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 adacea0..f6b4c30 100644
--- a/nn/common/operations/BidirectionalSequenceRNN.cpp
+++ b/nn/common/operations/BidirectionalSequenceRNN.cpp
@@ -335,11 +335,11 @@
     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 cf75f3a..ce1320f 100644
--- a/nn/common/operations/Broadcast.cpp
+++ b/nn/common/operations/Broadcast.cpp
@@ -434,19 +434,19 @@
 }  // 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 @@
             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 779a8d8..59726fa 100644
--- a/nn/common/operations/ChannelShuffle.cpp
+++ b/nn/common/operations/ChannelShuffle.cpp
@@ -73,9 +73,9 @@
     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 50ed806..8fdf72c 100644
--- a/nn/common/operations/Comparisons.cpp
+++ b/nn/common/operations/Comparisons.cpp
@@ -136,9 +136,9 @@
     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 6de5bad..cadfd0f 100644
--- a/nn/common/operations/Concatenation.cpp
+++ b/nn/common/operations/Concatenation.cpp
@@ -141,17 +141,17 @@
     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 5b7d8d0..5a5e337 100644
--- a/nn/common/operations/Conv2D.cpp
+++ b/nn/common/operations/Conv2D.cpp
@@ -613,13 +613,13 @@
     }
 
     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 47bf010..611e38d 100644
--- a/nn/common/operations/DepthwiseConv2D.cpp
+++ b/nn/common/operations/DepthwiseConv2D.cpp
@@ -496,13 +496,13 @@
     }
 
     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 7b81143..f155eb2 100644
--- a/nn/common/operations/Dequantize.cpp
+++ b/nn/common/operations/Dequantize.cpp
@@ -89,7 +89,7 @@
 
     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 @@
     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 3ddae90..a0cd78f 100644
--- a/nn/common/operations/Elementwise.cpp
+++ b/nn/common/operations/Elementwise.cpp
@@ -91,7 +91,7 @@
             << "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 @@
             << "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 @@
         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 dfb221c..0c72cb3 100644
--- a/nn/common/operations/Elu.cpp
+++ b/nn/common/operations/Elu.cpp
@@ -57,7 +57,7 @@
     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 5ff26e8..b967f1f 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 10e2e33..07ba096 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 a233627..f3b470e 100644
--- a/nn/common/operations/Fill.cpp
+++ b/nn/common/operations/Fill.cpp
@@ -77,7 +77,7 @@
     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 9fcc072..7c8c4e3 100644
--- a/nn/common/operations/FullyConnected.cpp
+++ b/nn/common/operations/FullyConnected.cpp
@@ -224,7 +224,7 @@
     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 @@
                 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 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 @@
                 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 e73a22e..6707b6d 100644
--- a/nn/common/operations/Gather.cpp
+++ b/nn/common/operations/Gather.cpp
@@ -73,9 +73,9 @@
                                     {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 2ef733e..edd7cb0 100644
--- a/nn/common/operations/GenerateProposals.cpp
+++ b/nn/common/operations/GenerateProposals.cpp
@@ -220,7 +220,7 @@
     }
     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 @@
     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 @@
     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 @@
     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 cfb9d98..4773a17 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 ff62006..9010344 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 a07e142..1da7ed0 100644
--- a/nn/common/operations/HeatmapMaxKeypoint.cpp
+++ b/nn/common/operations/HeatmapMaxKeypoint.cpp
@@ -230,7 +230,7 @@
     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 @@
                            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 0ce21d0..62b7728 100644
--- a/nn/common/operations/InstanceNormalization.cpp
+++ b/nn/common/operations/InstanceNormalization.cpp
@@ -116,7 +116,7 @@
     }
     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 f86ab80..49cc15d 100644
--- a/nn/common/operations/L2Normalization.cpp
+++ b/nn/common/operations/L2Normalization.cpp
@@ -204,19 +204,19 @@
     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 8e27b64..4182303 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 6fbc5d1..46661cf 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 1cac0df..a856c5f 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 26a7a00..6276168 100644
--- a/nn/common/operations/LocalResponseNormalization.cpp
+++ b/nn/common/operations/LocalResponseNormalization.cpp
@@ -139,14 +139,14 @@
     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 @@
 
     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 fdcccf8..86a882f 100644
--- a/nn/common/operations/LogSoftmax.cpp
+++ b/nn/common/operations/LogSoftmax.cpp
@@ -88,7 +88,7 @@
     }
     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 9d7e5ce..163aa54 100644
--- a/nn/common/operations/LogicalAndOr.cpp
+++ b/nn/common/operations/LogicalAndOr.cpp
@@ -68,7 +68,7 @@
             << "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 c715388..2f6bb63 100644
--- a/nn/common/operations/LogicalNot.cpp
+++ b/nn/common/operations/LogicalNot.cpp
@@ -49,7 +49,7 @@
             << "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 339172f..0b27e27 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 80fb7e8..6521bc7 100644
--- a/nn/common/operations/Multinomial.cpp
+++ b/nn/common/operations/Multinomial.cpp
@@ -18,19 +18,18 @@
 
 #include "Multinomial.h"
 
-#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>
 
+#include "CpuExecutor.h"
+#include "CpuOperationUtils.h"
+#include "Tracing.h"
+#include "guarded_philox_random.h"
+#include "philox_random.h"
+#include "simple_philox.h"
+
 namespace android {
 namespace nn {
 
diff --git a/nn/common/operations/Neg.cpp b/nn/common/operations/Neg.cpp
index bf21727..1d042fc 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 @@
             << "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 7e0c8c3..db2f6d4 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 @@
     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 62594c7..bc6571d 100644
--- a/nn/common/operations/Pooling.cpp
+++ b/nn/common/operations/Pooling.cpp
@@ -294,13 +294,13 @@
     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 @@
         };
     } 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 @@
         };
     } 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 @@
     }
     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 03892a2..2506549 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 68a9489..0812e66 100644
--- a/nn/common/operations/QLSTM.cpp
+++ b/nn/common/operations/QLSTM.cpp
@@ -149,7 +149,7 @@
     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 943a33d..c3f4812 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 @@
                  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 f07bc0a..590bdb9 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 0db5106..00b3b56 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 f584f0e..bc5a819 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 66acac7..d125586 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 8a6931b..71951d7 100644
--- a/nn/common/operations/Rank.cpp
+++ b/nn/common/operations/Rank.cpp
@@ -46,7 +46,7 @@
                  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 c56771c..0563a35 100644
--- a/nn/common/operations/Reduce.cpp
+++ b/nn/common/operations/Reduce.cpp
@@ -80,7 +80,7 @@
     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 @@
     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 @@
     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 9042099..a1acf18 100644
--- a/nn/common/operations/ResizeImageOps.cpp
+++ b/nn/common/operations/ResizeImageOps.cpp
@@ -187,13 +187,13 @@
                  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 @@
         }
     }
     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 01008cc..78049b8 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 @@
     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 373669a..a011b4a 100644
--- a/nn/common/operations/RoiPooling.cpp
+++ b/nn/common/operations/RoiPooling.cpp
@@ -216,10 +216,10 @@
     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 953e2a8..5904936 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 21f769f..09651d7 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 9105389..0b7728a 100644
--- a/nn/common/operations/Select.cpp
+++ b/nn/common/operations/Select.cpp
@@ -78,7 +78,7 @@
             << "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 1b5a493..3cf3c8a 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 @@
                  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 bb85c0b..a937395 100644
--- a/nn/common/operations/Softmax.cpp
+++ b/nn/common/operations/Softmax.cpp
@@ -233,13 +233,13 @@
     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 @@
         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 1b39162..441b5a2 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 d734550..e9640b9 100644
--- a/nn/common/operations/Squeeze.cpp
+++ b/nn/common/operations/Squeeze.cpp
@@ -45,13 +45,13 @@
                  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 @@
     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 3bb3a82..654659a 100644
--- a/nn/common/operations/StridedSlice.cpp
+++ b/nn/common/operations/StridedSlice.cpp
@@ -106,13 +106,13 @@
                  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 @@
     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 af17df1..da794a5 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 9e4ceed..d91c813 100644
--- a/nn/common/operations/TopK_V2.cpp
+++ b/nn/common/operations/TopK_V2.cpp
@@ -85,11 +85,11 @@
             << "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 423b3de..3bc76f0 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 @@
 
     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 0ee5d04..78d857a 100644
--- a/nn/common/operations/TransposeConv2D.cpp
+++ b/nn/common/operations/TransposeConv2D.cpp
@@ -440,7 +440,7 @@
     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 @@
         }
         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 @@
                             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 9a00e1f..02da158 100644
--- a/nn/common/operations/UnidirectionalSequenceLSTM.cpp
+++ b/nn/common/operations/UnidirectionalSequenceLSTM.cpp
@@ -156,14 +156,14 @@
                 << "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 aa79739..382aa58 100644
--- a/nn/common/operations/UnidirectionalSequenceRNN.cpp
+++ b/nn/common/operations/UnidirectionalSequenceRNN.cpp
@@ -139,13 +139,13 @@
     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) {