From 6550617b507b3928f88ab4179a304458005b527a Mon Sep 17 00:00:00 2001 From: Anoob Anto K Date: Tue, 22 Nov 2022 05:16:45 +0000 Subject: [PATCH] Re-enable Operations that were disabled due to CTS errors Certain operations were disabled and limitations were applied to a few other operations as part of OAM-102888 : e19bead, 0722c03. These changes were needed due to the CTS failures observed on Android_S while using NNHAL1.3. Here, we are re-enabling these operations since it is blocking many usecases like Image Classification, etc. Tracked-On: OAM-105480 Signed-off-by: Anoob Anto K --- .../operations/include/DepthToSpace.hpp | 1 - .../operations/include/Dequantize.hpp | 1 - ngraph_creator/operations/include/Div.hpp | 1 - .../operations/include/L2Pooling2D.hpp | 1 - ngraph_creator/operations/include/Less.hpp | 1 - .../operations/include/Logistic.hpp | 1 - .../operations/include/MaxPool2d.hpp | 1 - ngraph_creator/operations/include/Mul.hpp | 1 - .../operations/include/Quantize.hpp | 1 - .../operations/include/ReduceMin.hpp | 1 - .../operations/include/ReduceSum.hpp | 1 - ngraph_creator/operations/include/Relu.hpp | 1 - ngraph_creator/operations/include/Relu1.hpp | 1 - ngraph_creator/operations/include/Relu6.hpp | 1 - ngraph_creator/operations/include/Softmax.hpp | 1 - ngraph_creator/operations/include/Sub.hpp | 1 - ngraph_creator/operations/include/Tanh.hpp | 1 - ngraph_creator/operations/src/Add.cpp | 25 ++++------------- .../operations/src/AveragePool2D.cpp | 5 ---- .../operations/src/DepthToSpace.cpp | 24 ---------------- ngraph_creator/operations/src/Dequantize.cpp | 10 ------- ngraph_creator/operations/src/Div.cpp | 27 ------------------ .../operations/src/FullyConnected.cpp | 12 -------- ngraph_creator/operations/src/L2Pooling2D.cpp | 16 ----------- ngraph_creator/operations/src/Less.cpp | 19 ------------- ngraph_creator/operations/src/Logistic.cpp | 16 ----------- ngraph_creator/operations/src/MaxPool2d.cpp | 16 ----------- ngraph_creator/operations/src/Mul.cpp | 28 ------------------- .../operations/src/OperationsBase.cpp | 2 +- ngraph_creator/operations/src/Quantize.cpp | 10 ------- ngraph_creator/operations/src/ReduceMin.cpp | 19 ------------- ngraph_creator/operations/src/ReduceSum.cpp | 19 ------------- ngraph_creator/operations/src/Relu.cpp | 10 ------- ngraph_creator/operations/src/Relu1.cpp | 10 ------- ngraph_creator/operations/src/Relu6.cpp | 10 ------- ngraph_creator/operations/src/Reshape.cpp | 13 +++------ ngraph_creator/operations/src/Softmax.cpp | 11 -------- .../operations/src/SpaceToBatch.cpp | 18 +++++------- ngraph_creator/operations/src/Squeeze.cpp | 27 ++++-------------- ngraph_creator/operations/src/Sub.cpp | 27 ------------------ ngraph_creator/operations/src/Tanh.cpp | 11 -------- ngraph_creator/operations/src/Transpose.cpp | 28 +++++++------------ .../operations/src/TransposeConv2D.cpp | 12 ++------ ngraph_creator/src/OperationsFactory.cpp | 20 ++++++------- 44 files changed, 45 insertions(+), 417 deletions(-) diff --git a/ngraph_creator/operations/include/DepthToSpace.hpp b/ngraph_creator/operations/include/DepthToSpace.hpp index 46242e1e7..51dacccb0 100644 --- a/ngraph_creator/operations/include/DepthToSpace.hpp +++ b/ngraph_creator/operations/include/DepthToSpace.hpp @@ -10,7 +10,6 @@ namespace nnhal { class DepthToSpace : public OperationsBase { public: DepthToSpace(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Dequantize.hpp b/ngraph_creator/operations/include/Dequantize.hpp index a77fc86d3..4e9248a9e 100644 --- a/ngraph_creator/operations/include/Dequantize.hpp +++ b/ngraph_creator/operations/include/Dequantize.hpp @@ -11,7 +11,6 @@ class Dequantize : public OperationsBase { public: Dequantize(int operationIndex); std::shared_ptr createNode() override; - bool validate() override; }; } // namespace nnhal diff --git a/ngraph_creator/operations/include/Div.hpp b/ngraph_creator/operations/include/Div.hpp index 0e3f9686c..6a78e9b53 100644 --- a/ngraph_creator/operations/include/Div.hpp +++ b/ngraph_creator/operations/include/Div.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Div : public OperationsBase { public: Div(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/L2Pooling2D.hpp b/ngraph_creator/operations/include/L2Pooling2D.hpp index 354ada6bb..ba9e7015f 100644 --- a/ngraph_creator/operations/include/L2Pooling2D.hpp +++ b/ngraph_creator/operations/include/L2Pooling2D.hpp @@ -10,7 +10,6 @@ namespace nnhal { class L2Pooling2D : public OperationsBase { public: L2Pooling2D(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Less.hpp b/ngraph_creator/operations/include/Less.hpp index 45058c56b..612df2660 100644 --- a/ngraph_creator/operations/include/Less.hpp +++ b/ngraph_creator/operations/include/Less.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Less : public OperationsBase { public: Less(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Logistic.hpp b/ngraph_creator/operations/include/Logistic.hpp index 85dea4a8c..d7bdf09fb 100644 --- a/ngraph_creator/operations/include/Logistic.hpp +++ b/ngraph_creator/operations/include/Logistic.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Logistic : public OperationsBase { public: Logistic(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/MaxPool2d.hpp b/ngraph_creator/operations/include/MaxPool2d.hpp index 52fd38e1f..58acc2645 100644 --- a/ngraph_creator/operations/include/MaxPool2d.hpp +++ b/ngraph_creator/operations/include/MaxPool2d.hpp @@ -10,7 +10,6 @@ namespace nnhal { class MaxPool2d : public OperationsBase { public: MaxPool2d(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Mul.hpp b/ngraph_creator/operations/include/Mul.hpp index 77a70e704..77687ba1e 100644 --- a/ngraph_creator/operations/include/Mul.hpp +++ b/ngraph_creator/operations/include/Mul.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Mul : public OperationsBase { public: Mul(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Quantize.hpp b/ngraph_creator/operations/include/Quantize.hpp index 95940a0c2..73c36c7e8 100644 --- a/ngraph_creator/operations/include/Quantize.hpp +++ b/ngraph_creator/operations/include/Quantize.hpp @@ -11,7 +11,6 @@ class Quantize : public OperationsBase { public: Quantize(int operationIndex); std::shared_ptr createNode() override; - bool validate() override; void connectOperationToGraph() override; }; diff --git a/ngraph_creator/operations/include/ReduceMin.hpp b/ngraph_creator/operations/include/ReduceMin.hpp index 44deef838..577d5f1fd 100644 --- a/ngraph_creator/operations/include/ReduceMin.hpp +++ b/ngraph_creator/operations/include/ReduceMin.hpp @@ -10,7 +10,6 @@ namespace nnhal { class ReduceMin : public OperationsBase { public: ReduceMin(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/ReduceSum.hpp b/ngraph_creator/operations/include/ReduceSum.hpp index 145170f6b..62591963c 100644 --- a/ngraph_creator/operations/include/ReduceSum.hpp +++ b/ngraph_creator/operations/include/ReduceSum.hpp @@ -10,7 +10,6 @@ namespace nnhal { class ReduceSum : public OperationsBase { public: ReduceSum(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Relu.hpp b/ngraph_creator/operations/include/Relu.hpp index 730fbe4df..cff5fd250 100644 --- a/ngraph_creator/operations/include/Relu.hpp +++ b/ngraph_creator/operations/include/Relu.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Relu : public OperationsBase { public: Relu(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Relu1.hpp b/ngraph_creator/operations/include/Relu1.hpp index fc4114a03..81127ca0f 100644 --- a/ngraph_creator/operations/include/Relu1.hpp +++ b/ngraph_creator/operations/include/Relu1.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Relu1 : public OperationsBase { public: Relu1(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Relu6.hpp b/ngraph_creator/operations/include/Relu6.hpp index cbd1cb715..b06aeadbc 100644 --- a/ngraph_creator/operations/include/Relu6.hpp +++ b/ngraph_creator/operations/include/Relu6.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Relu6 : public OperationsBase { public: Relu6(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Softmax.hpp b/ngraph_creator/operations/include/Softmax.hpp index fbca45961..4241b7209 100644 --- a/ngraph_creator/operations/include/Softmax.hpp +++ b/ngraph_creator/operations/include/Softmax.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Softmax : public OperationsBase { public: Softmax(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Sub.hpp b/ngraph_creator/operations/include/Sub.hpp index ca99958b2..af217602d 100644 --- a/ngraph_creator/operations/include/Sub.hpp +++ b/ngraph_creator/operations/include/Sub.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Sub : public OperationsBase { public: Sub(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/include/Tanh.hpp b/ngraph_creator/operations/include/Tanh.hpp index 90e92f8a8..3ecfd5019 100644 --- a/ngraph_creator/operations/include/Tanh.hpp +++ b/ngraph_creator/operations/include/Tanh.hpp @@ -10,7 +10,6 @@ namespace nnhal { class Tanh : public OperationsBase { public: Tanh(int operationIndex); - bool validate() override; std::shared_ptr createNode() override; }; diff --git a/ngraph_creator/operations/src/Add.cpp b/ngraph_creator/operations/src/Add.cpp index 3058086b1..702845cc0 100644 --- a/ngraph_creator/operations/src/Add.cpp +++ b/ngraph_creator/operations/src/Add.cpp @@ -12,29 +12,14 @@ Add::Add(int operationIndex) : OperationsBase(operationIndex) { } bool Add::validate() { - auto operandIndex1 = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); - auto operandIndex2 = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - const auto& elementType1 = sModelInfo->getOperandType(operandIndex1); - const auto& elementType2 = sModelInfo->getOperandType(operandIndex2); - if ( !isValidInputTensor(0) || !isValidInputTensor(1) ) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } + ALOGV("%s PASSED", __func__); - // check if both tensors are of same type - if(elementType1 != elementType2 ) { - ALOGE("%s Input type mismatch", __func__); + const auto& activationIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); + if (!sModelInfo->isOperandLifeTimeConst(activationIndex)) { + ALOGE("%s Only Constant supported for specifying Activation", __func__); return false; - } else if ( elementType1 == OperandType::TENSOR_INT32 ) { - //In 1.3 For a {@link OperandType::TENSOR_INT32} tensor, - //the {@link FusedActivationFunc} must be "NONE". - auto activationFn = sModelInfo->ParseOperationInput(mNnapiOperationIndex, 2); - if (activationFn != 0) { - ALOGE("%s Activation type must be none for TENSOR_INT32 type", __func__); - return false; - } } - ALOGV("%s PASSED", __func__); + return true; } diff --git a/ngraph_creator/operations/src/AveragePool2D.cpp b/ngraph_creator/operations/src/AveragePool2D.cpp index dc49baed8..f72c71486 100644 --- a/ngraph_creator/operations/src/AveragePool2D.cpp +++ b/ngraph_creator/operations/src/AveragePool2D.cpp @@ -18,11 +18,6 @@ bool AveragePool2D::validate() { ALOGE("%s Invalid dimensions size for input(%lu)", __func__, inputDimensionsSize); return false; } - //check Input are of valid dimension or not - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } ALOGV("%s PASSED", __func__); return true; diff --git a/ngraph_creator/operations/src/DepthToSpace.cpp b/ngraph_creator/operations/src/DepthToSpace.cpp index 0ffb807c3..dbf30743f 100644 --- a/ngraph_creator/operations/src/DepthToSpace.cpp +++ b/ngraph_creator/operations/src/DepthToSpace.cpp @@ -11,30 +11,6 @@ DepthToSpace::DepthToSpace(int operationIndex) : OperationsBase(operationIndex) mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool DepthToSpace::validate() { - // Check input rank - const auto inputRank = getInputOperandDimensions(0).size(); - - if (inputRank != 4) { - ALOGE("%s Invalid dimension of rank %d", __func__, inputRank); - return false; - } - - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - auto block_size = sModelInfo->ParseOperationInput(mNnapiOperationIndex, 1); - if(block_size < 1) { - ALOGE("%s Invalid block size %d", __func__, block_size); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr DepthToSpace::createNode() { // Creating input nodes std::shared_ptr input; diff --git a/ngraph_creator/operations/src/Dequantize.cpp b/ngraph_creator/operations/src/Dequantize.cpp index d3a529c45..85c19eb7b 100644 --- a/ngraph_creator/operations/src/Dequantize.cpp +++ b/ngraph_creator/operations/src/Dequantize.cpp @@ -11,16 +11,6 @@ Dequantize::Dequantize(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Dequantize::validate() { - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Dequantize::createNode() { // Creating input nodes std::shared_ptr input, outputNode; diff --git a/ngraph_creator/operations/src/Div.cpp b/ngraph_creator/operations/src/Div.cpp index 37f0d8805..a89995f8f 100644 --- a/ngraph_creator/operations/src/Div.cpp +++ b/ngraph_creator/operations/src/Div.cpp @@ -11,33 +11,6 @@ Div::Div(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Div::validate() { - auto operandIndex1 = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); - auto operandIndex2 = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - const auto& elementType1 = sModelInfo->getOperandType(operandIndex1); - const auto& elementType2 = sModelInfo->getOperandType(operandIndex2); - if ( !isValidInputTensor(0) || !isValidInputTensor(1) ) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - // check if both tensors are of same type - if(elementType1 != elementType2 ) { - ALOGE("%s Input type mismatch", __func__); - return false; - } else if ( elementType1 == OperandType::TENSOR_INT32 ) { - //In 1.3 For a {@link OperandType::TENSOR_INT32} tensor, - //the {@link FusedActivationFunc} must be "NONE". - auto activationFn = sModelInfo->ParseOperationInput(mNnapiOperationIndex, 2); - if (activationFn != 0) { - ALOGE("%s Activation type must be none for TENSOR_INT32 type", __func__); - return false; - } - } - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Div::createNode() { // Creating input nodes auto input1 = getInputNode(0); diff --git a/ngraph_creator/operations/src/FullyConnected.cpp b/ngraph_creator/operations/src/FullyConnected.cpp index 5dcb7218e..7771c66fa 100644 --- a/ngraph_creator/operations/src/FullyConnected.cpp +++ b/ngraph_creator/operations/src/FullyConnected.cpp @@ -25,18 +25,6 @@ bool FullyConnected::validate() { ALOGE("%s Invalid input parameter dimensions!!!", __func__); return false; } - //check operand lifetime - const auto& dimsOperandIndex1 = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); - const auto& dimsOperandIndex2 = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - const auto& dimsOperandIndex3 = sModelInfo->getOperationInput(mNnapiOperationIndex, 2); - const auto& dimsOperandIndex4 = sModelInfo->getOperationInput(mNnapiOperationIndex, 3); - if(!sModelInfo->isOperandLifeTimeConst(dimsOperandIndex1) || - !sModelInfo->isOperandLifeTimeConst(dimsOperandIndex2) || - !sModelInfo->isOperandLifeTimeConst(dimsOperandIndex3) || - !sModelInfo->isOperandLifeTimeConst(dimsOperandIndex4)) { - ALOGE("%s Only Const lifetime is supported", __func__); - return false; - } ALOGD("%s succeeded", __func__); return true; diff --git a/ngraph_creator/operations/src/L2Pooling2D.cpp b/ngraph_creator/operations/src/L2Pooling2D.cpp index 0e11e52a7..d8520b132 100644 --- a/ngraph_creator/operations/src/L2Pooling2D.cpp +++ b/ngraph_creator/operations/src/L2Pooling2D.cpp @@ -11,22 +11,6 @@ L2Pooling2D::L2Pooling2D(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool L2Pooling2D::validate() { - const auto& inputDimensionsSize = getInputOperandDimensions(0).size(); - if (inputDimensionsSize != 4) { - ALOGE("%s Invalid dimensions size for input(%lu)", __func__, inputDimensionsSize); - return false; - } - //check Input are of valid dimension or not - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr L2Pooling2D::createNode() { const auto& inputsSize = sModelInfo->getOperationInputsSize(mNnapiOperationIndex); bool isImplicit = false, isExplicit = false; diff --git a/ngraph_creator/operations/src/Less.cpp b/ngraph_creator/operations/src/Less.cpp index 38f5b328a..c521414b3 100644 --- a/ngraph_creator/operations/src/Less.cpp +++ b/ngraph_creator/operations/src/Less.cpp @@ -11,25 +11,6 @@ Less::Less(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Less::validate() { - auto operandIndex1 = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); - auto operandIndex2 = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - const auto& elementType1 = sModelInfo->getOperandType(operandIndex1); - const auto& elementType2 = sModelInfo->getOperandType(operandIndex2); - if ( !isValidInputTensor(0) || !isValidInputTensor(1) ) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - // check if both tensors are of same type - if(elementType1 != elementType2 ) { - ALOGE("%s Input type mismatch", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} std::shared_ptr Less::createNode() { // Creating input nodes std::shared_ptr input1, input2; diff --git a/ngraph_creator/operations/src/Logistic.cpp b/ngraph_creator/operations/src/Logistic.cpp index a6aa88e46..f134cb956 100644 --- a/ngraph_creator/operations/src/Logistic.cpp +++ b/ngraph_creator/operations/src/Logistic.cpp @@ -11,22 +11,6 @@ Logistic::Logistic(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Logistic::validate() { - const auto& inputDimensionsSize = getInputOperandDimensions(0).size(); - if (inputDimensionsSize > 4) { - ALOGE("%s Invalid dimensions size for input(%lu)", __func__, inputDimensionsSize); - return false; - } - //check Input are of valid dimension or not - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Logistic::createNode() { // Creating input nodes std::shared_ptr input; diff --git a/ngraph_creator/operations/src/MaxPool2d.cpp b/ngraph_creator/operations/src/MaxPool2d.cpp index ab613f52a..bf320b897 100644 --- a/ngraph_creator/operations/src/MaxPool2d.cpp +++ b/ngraph_creator/operations/src/MaxPool2d.cpp @@ -11,22 +11,6 @@ MaxPool2d::MaxPool2d(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool MaxPool2d::validate() { - // Check Input Dimension size - const auto& inputDimensionsSize = getInputOperandDimensions(0).size(); - if (inputDimensionsSize != 4) { - ALOGE("%s Invalid dimensions size for input(%lu)", __func__, inputDimensionsSize); - return false; - } - //check Input are of valid dimension or not - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} std::shared_ptr MaxPool2d::createNode() { const auto& inputsSize = sModelInfo->getOperationInputsSize(mNnapiOperationIndex); ALOGD("%s inputsSize %lu", __func__, inputsSize); diff --git a/ngraph_creator/operations/src/Mul.cpp b/ngraph_creator/operations/src/Mul.cpp index 0c5501cab..84a3e647b 100644 --- a/ngraph_creator/operations/src/Mul.cpp +++ b/ngraph_creator/operations/src/Mul.cpp @@ -11,34 +11,6 @@ Mul::Mul(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Mul::validate() { - auto operandIndex1 = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); - auto operandIndex2 = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - const auto& elementType1 = sModelInfo->getOperandType(operandIndex1); - const auto& elementType2 = sModelInfo->getOperandType(operandIndex2); - - if ( !isValidInputTensor(0) || !isValidInputTensor(1) ) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - if(elementType1 != elementType2 ) { - ALOGE("%s Input type mismatch", __func__); - return false; - } else if ( elementType1 == OperandType::TENSOR_INT32 ) { - //In 1.3 For a {@link OperandType::TENSOR_INT32} tensor, - //the {@link FusedActivationFunc} must be "NONE". - auto activationFn = sModelInfo->ParseOperationInput(mNnapiOperationIndex, 2); - if (activationFn != 0) { - ALOGE("%s Activation type must be none for TENSOR_INT32 type", __func__); - return false; - } - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Mul::createNode() { // Creating input nodes std::shared_ptr input1, input2; diff --git a/ngraph_creator/operations/src/OperationsBase.cpp b/ngraph_creator/operations/src/OperationsBase.cpp index 020033eff..3df23c0f9 100755 --- a/ngraph_creator/operations/src/OperationsBase.cpp +++ b/ngraph_creator/operations/src/OperationsBase.cpp @@ -109,7 +109,7 @@ bool OperationsBase::checkOperandType(uint32_t operandIndex, const int32_t expec const std::string& strLogInfo) { const auto operandType = (int32_t)sModelInfo->getOperandType(operandIndex); if (operandType != expectedOperandType) { - ALOGV("OperationIndex %d %s Index %d type %d invalid", mNnapiOperationIndex, + ALOGE("OperationIndex %d %s Index %d type %d invalid", mNnapiOperationIndex, strLogInfo.c_str(), operandIndex, operandType); return false; } diff --git a/ngraph_creator/operations/src/Quantize.cpp b/ngraph_creator/operations/src/Quantize.cpp index 02809b29b..24c09174d 100755 --- a/ngraph_creator/operations/src/Quantize.cpp +++ b/ngraph_creator/operations/src/Quantize.cpp @@ -11,16 +11,6 @@ Quantize::Quantize(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Quantize::validate() { - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - void Quantize::connectOperationToGraph() { createNode(); } std::shared_ptr Quantize::createNode() { diff --git a/ngraph_creator/operations/src/ReduceMin.cpp b/ngraph_creator/operations/src/ReduceMin.cpp index 6a20937c9..4eec8b34f 100644 --- a/ngraph_creator/operations/src/ReduceMin.cpp +++ b/ngraph_creator/operations/src/ReduceMin.cpp @@ -11,25 +11,6 @@ ReduceMin::ReduceMin(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool ReduceMin::validate() { - // Check input rank - const auto inputRank = getInputOperandDimensions(0).size(); - - if (inputRank > 4) - return false; - - if ( !isValidInputTensor(0) || !isValidInputTensor(1)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - auto& input_OperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); - auto& dim_reduce_OperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr ReduceMin::createNode() { // Creating input nodes std::shared_ptr input; diff --git a/ngraph_creator/operations/src/ReduceSum.cpp b/ngraph_creator/operations/src/ReduceSum.cpp index 937d1bb69..e60859c12 100644 --- a/ngraph_creator/operations/src/ReduceSum.cpp +++ b/ngraph_creator/operations/src/ReduceSum.cpp @@ -11,25 +11,6 @@ ReduceSum::ReduceSum(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool ReduceSum::validate() { - // Check input rank - const auto inputRank = getInputOperandDimensions(0).size(); - - if (inputRank > 4) - return false; - - if ( !isValidInputTensor(0) || !isValidInputTensor(1)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - auto& input_OperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); - auto& dim_reduce_OperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr ReduceSum::createNode() { // Creating input nodes auto input = getInputNode(0); diff --git a/ngraph_creator/operations/src/Relu.cpp b/ngraph_creator/operations/src/Relu.cpp index e8dce05c0..815dd7914 100644 --- a/ngraph_creator/operations/src/Relu.cpp +++ b/ngraph_creator/operations/src/Relu.cpp @@ -11,16 +11,6 @@ Relu::Relu(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Relu::validate() { - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Relu::createNode() { // Creating input nodes std::shared_ptr input; diff --git a/ngraph_creator/operations/src/Relu1.cpp b/ngraph_creator/operations/src/Relu1.cpp index 2d8e648a3..4c5a40799 100644 --- a/ngraph_creator/operations/src/Relu1.cpp +++ b/ngraph_creator/operations/src/Relu1.cpp @@ -11,16 +11,6 @@ Relu1::Relu1(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Relu1::validate() { - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Relu1::createNode() { // Creating input nodes std::shared_ptr input; diff --git a/ngraph_creator/operations/src/Relu6.cpp b/ngraph_creator/operations/src/Relu6.cpp index 68533e9ca..3f16afe5d 100644 --- a/ngraph_creator/operations/src/Relu6.cpp +++ b/ngraph_creator/operations/src/Relu6.cpp @@ -11,16 +11,6 @@ Relu6::Relu6(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Relu6::validate() { - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Relu6::createNode() { // Creating input nodes std::shared_ptr input; diff --git a/ngraph_creator/operations/src/Reshape.cpp b/ngraph_creator/operations/src/Reshape.cpp index 1cfe737b7..39556276a 100644 --- a/ngraph_creator/operations/src/Reshape.cpp +++ b/ngraph_creator/operations/src/Reshape.cpp @@ -12,17 +12,12 @@ Reshape::Reshape(int operationIndex) : OperationsBase(operationIndex) { } bool Reshape::validate() { - const auto inputRank = getInputOperandDimensions(0).size(); - if (!isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); + const auto& dimsOperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); + if (!sModelInfo->isOperandLifeTimeConst(dimsOperandIndex) || !isValidInputTensor(1)) { + // TODO: Support CPU_reshape_all_tensors_as_inputs + ALOGE("%s Only Constant non-zero dimensions supported now", __func__); return false; } - - if (inputRank > 4) { - ALOGE("%s Invalid dimensions size for input", __func__); - return false; - } - ALOGV("%s PASSED", __func__); return true; } diff --git a/ngraph_creator/operations/src/Softmax.cpp b/ngraph_creator/operations/src/Softmax.cpp index 80ea14212..18f1bcdea 100644 --- a/ngraph_creator/operations/src/Softmax.cpp +++ b/ngraph_creator/operations/src/Softmax.cpp @@ -11,17 +11,6 @@ Softmax::Softmax(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Softmax::validate() { - const auto inputRank = getInputOperandDimensions(0).size(); - if ( !isValidInputTensor(0) || inputRank > 4 ) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Softmax::createNode() { // Creating input nodes std::shared_ptr input, outputNode; diff --git a/ngraph_creator/operations/src/SpaceToBatch.cpp b/ngraph_creator/operations/src/SpaceToBatch.cpp index f925e039a..976c16e7d 100644 --- a/ngraph_creator/operations/src/SpaceToBatch.cpp +++ b/ngraph_creator/operations/src/SpaceToBatch.cpp @@ -16,21 +16,17 @@ bool SpaceToBatch::validate() { const auto inputRank = getInputOperandDimensions(0).size(); if (inputRank != 4) return false; - if ( !isValidInputTensor(0) || !isValidInputTensor(1) || !isValidInputTensor(2) ) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - auto& input_OperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); auto& block_shape_OperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - auto& pad_OperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 2); + // TODO: Add Support for all_tensors_as_inputs + if (!sModelInfo->isOperandLifeTimeConst(block_shape_OperandIndex)) { + ALOGE("%s Only Constant dimensions supported now", __func__); + return false; + } - //check operand lifetime is const or not as for now only const operand lifetime is supported + auto pad_OperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 2); // TODO: Add Support for all_tensors_as_inputs - if (!sModelInfo->isOperandLifeTimeConst(input_OperandIndex) || - !sModelInfo->isOperandLifeTimeConst(block_shape_OperandIndex) || - !sModelInfo->isOperandLifeTimeConst(pad_OperandIndex)) { + if (!sModelInfo->isOperandLifeTimeConst(pad_OperandIndex)) { ALOGE("%s Only Constant dimensions supported now", __func__); return false; } diff --git a/ngraph_creator/operations/src/Squeeze.cpp b/ngraph_creator/operations/src/Squeeze.cpp index 0364fd875..bb466e793 100644 --- a/ngraph_creator/operations/src/Squeeze.cpp +++ b/ngraph_creator/operations/src/Squeeze.cpp @@ -12,32 +12,17 @@ Squeeze::Squeeze(int operationIndex) : OperationsBase(operationIndex) { } bool Squeeze::validate() { - const auto inputRank = getInputOperandDimensions(0).size(); - if (inputRank > 4) return false; - - if ( !isValidInputTensor(0)) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } // TODO: Add Support for all_tensors_as_inputs - const auto& dimsOperandIndex1 = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); + const auto& dimsOperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - if (!sModelInfo->isOperandLifeTimeConst(dimsOperandIndex1)) { + // TODO: Support OmittedInput. + // The empty 2nd argument in Squeeze op causes dynamic output + // To add support, the dims will have to be calculated statically + if (sModelInfo->isOmittedInput(mNnapiOperationIndex, 1) || + !sModelInfo->isOperandLifeTimeConst(dimsOperandIndex)) { ALOGE("%s Only Constant dimensions supported now", __func__); return false; } - const auto& inputsSize = sModelInfo->getOperationInputsSize(mNnapiOperationIndex); - if (inputsSize == 2) { - const auto& dimsOperandIndex2 = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - // TODO: Support OmittedInput. - // The empty 2nd argument in Squeeze op causes dynamic output - // To add support, the dims will have to be calculated statically - if (!isValidInputTensor(1) || !sModelInfo->isOperandLifeTimeConst(dimsOperandIndex2) || - sModelInfo->isOmittedInput(mNnapiOperationIndex, 1) ) { - ALOGE("%s Invalid operand type or operand lifetime", __func__); - return false; - } - } return true; } diff --git a/ngraph_creator/operations/src/Sub.cpp b/ngraph_creator/operations/src/Sub.cpp index 51b3c8668..c90d7f7b5 100644 --- a/ngraph_creator/operations/src/Sub.cpp +++ b/ngraph_creator/operations/src/Sub.cpp @@ -11,33 +11,6 @@ Sub::Sub(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Sub::validate() { - auto operandIndex1 = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); - auto operandIndex2 = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - const auto& elementType1 = sModelInfo->getOperandType(operandIndex1); - const auto& elementType2 = sModelInfo->getOperandType(operandIndex2); - if ( !isValidInputTensor(0) || !isValidInputTensor(1) ) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - // check if both tensors are of same type - if(elementType1 != elementType2 ) { - ALOGE("%s Input type mismatch", __func__); - return false; - } else if ( elementType1 == OperandType::TENSOR_INT32 ) { - //In 1.3 For a {@link OperandType::TENSOR_INT32} tensor, - //the {@link FusedActivationFunc} must be "NONE". - auto activationFn = sModelInfo->ParseOperationInput(mNnapiOperationIndex, 2); - if (activationFn != 0) { - ALOGE("%s Activation type must be none for TENSOR_INT32 type", __func__); - return false; - } - } - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Sub::createNode() { // Creating input nodes std::shared_ptr input1, input2; diff --git a/ngraph_creator/operations/src/Tanh.cpp b/ngraph_creator/operations/src/Tanh.cpp index 7f3679489..65adaa342 100644 --- a/ngraph_creator/operations/src/Tanh.cpp +++ b/ngraph_creator/operations/src/Tanh.cpp @@ -11,17 +11,6 @@ Tanh::Tanh(int operationIndex) : OperationsBase(operationIndex) { mDefaultOutputIndex = sModelInfo->getOperationOutput(mNnapiOperationIndex, 0); } -bool Tanh::validate() { - const auto inputRank = getInputOperandDimensions(0).size(); - if ( !isValidInputTensor(0) || inputRank > 4 ) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; - } - - ALOGV("%s PASSED", __func__); - return true; -} - std::shared_ptr Tanh::createNode() { // Creating input nodes std::shared_ptr input; diff --git a/ngraph_creator/operations/src/Transpose.cpp b/ngraph_creator/operations/src/Transpose.cpp index 641b68799..052453386 100644 --- a/ngraph_creator/operations/src/Transpose.cpp +++ b/ngraph_creator/operations/src/Transpose.cpp @@ -13,23 +13,13 @@ Transpose::Transpose(int operationIndex) : OperationsBase(operationIndex) { bool Transpose::validate() { // TODO: Add Support for all_tensors_as_inputs - const auto& dimsOperandIndex1 = sModelInfo->getOperationInput(mNnapiOperationIndex, 0); - const auto inputRank = getInputOperandDimensions(0).size(); - if ( !isValidInputTensor(0) || inputRank > 4) { - ALOGE("%s Empty or Invalid dimensions size for input", __func__); - return false; + const auto& dimsOperandIndex = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); + const auto& dims = getInputOperandDimensions(1); + if (!dims.empty() && dims[0] != 0 && !sModelInfo->isOperandLifeTimeConst(dimsOperandIndex)) { + ALOGE("%s Only Constant dimensions supported now", __func__); + return false; } - const auto& inputsSize = sModelInfo->getOperationInputsSize(mNnapiOperationIndex); - if (inputsSize == 2) { - const auto& dimsOperandIndex2 = sModelInfo->getOperationInput(mNnapiOperationIndex, 1); - if (!isValidInputTensor(1) || !sModelInfo->isOperandLifeTimeConst(dimsOperandIndex2)) { - ALOGE("%s Invalid operand type or operand lifetime", __func__); - return false; - } - } - - ALOGV("%s PASSED", __func__); return true; } @@ -40,12 +30,14 @@ std::shared_ptr Transpose::createNode() { input = getInputNode(0); std::shared_ptr order; - order = createConstNode(ngraph::element::i32, {0}, convertToVector(0)); - const auto& inputsSize = sModelInfo->getOperationInputsSize(mNnapiOperationIndex); - if (inputsSize == 2) { + const auto& dims = getInputOperandDimensions(1); + if (!dims.empty() && dims[0] != 0) { order = getInputNode(1); + } else { + order = createConstNode(ngraph::element::i32, {0}, convertToVector(0)); } + std::shared_ptr outputNode; outputNode = std::make_shared(input, order); diff --git a/ngraph_creator/operations/src/TransposeConv2D.cpp b/ngraph_creator/operations/src/TransposeConv2D.cpp index a9e9c2d85..5b9d6999a 100644 --- a/ngraph_creator/operations/src/TransposeConv2D.cpp +++ b/ngraph_creator/operations/src/TransposeConv2D.cpp @@ -22,7 +22,7 @@ bool TransposeConv2D::validate() { inputDimensionsSize, filterDimensionsSize); return false; } - if (!isValidInputTensor(0) || !isValidInputTensor(1) || !isValidInputTensor(2)) { + if (!isValidInputTensor(0) || !isValidInputTensor(1)) { ALOGE("%s Invalid dimensions for input or filter", __func__); return false; } @@ -38,16 +38,8 @@ bool TransposeConv2D::validate() { // TODO: Issue from OV 2021.4, remove this check once CVS-61723 is resolved // Workaround to ignore VTS large input error test cases const auto& inputDimensions = getInputOperandDimensions(0); - const auto& filterDimensions = getInputOperandDimensions(1); - const auto& biasDimensions = getInputOperandDimensions(2); - if (inputDimensions[1] == 1 && inputDimensions[2] == 1 && inputDimensions[3] == 1) { - return false; - } - //check if the bias dimension == filter depth_out && filter depth_in == input depth_in - if(filterDimensions[0] != biasDimensions[0] && biasDimensions[3] != inputDimensions[3]) { - return false; - } + if (inputDimensions[1] == 1 && inputDimensions[2] == 1 && inputDimensions[3] == 1) return false; ALOGV("%s PASSED", __func__); return true; diff --git a/ngraph_creator/src/OperationsFactory.cpp b/ngraph_creator/src/OperationsFactory.cpp index 06a3bb811..f31deb796 100755 --- a/ngraph_creator/src/OperationsFactory.cpp +++ b/ngraph_creator/src/OperationsFactory.cpp @@ -26,8 +26,8 @@ std::shared_ptr OperationsFactory::getOperation( return std::make_shared(operationIndex); case OperationType::ARGMIN: return std::make_shared(operationIndex); - // case OperationType::AVERAGE_POOL_2D: - // return std::make_shared(operationIndex); + case OperationType::AVERAGE_POOL_2D: + return std::make_shared(operationIndex); case OperationType::BATCH_TO_SPACE_ND: return std::make_shared(operationIndex); case OperationType::BIDIRECTIONAL_SEQUENCE_RNN: @@ -70,10 +70,10 @@ std::shared_ptr OperationsFactory::getOperation( return std::make_shared(operationIndex); case OperationType::INSTANCE_NORMALIZATION: return std::make_shared(operationIndex); - // case OperationType::L2_POOL_2D: - // return std::make_shared(operationIndex); - // case OperationType::L2_NORMALIZATION: - // return std::make_shared(operationIndex); + case OperationType::L2_POOL_2D: + return std::make_shared(operationIndex); + case OperationType::L2_NORMALIZATION: + return std::make_shared(operationIndex); case OperationType::LSTM: return std::make_shared(operationIndex); case OperationType::LESS: @@ -144,10 +144,10 @@ std::shared_ptr OperationsFactory::getOperation( return std::make_shared(operationIndex); case OperationType::RSQRT: return std::make_shared(operationIndex); - // case OperationType::RESIZE_BILINEAR: - // return std::make_shared(operationIndex); - // case OperationType::RESIZE_NEAREST_NEIGHBOR: - // return std::make_shared(operationIndex); + case OperationType::RESIZE_BILINEAR: + return std::make_shared(operationIndex); + case OperationType::RESIZE_NEAREST_NEIGHBOR: + return std::make_shared(operationIndex); case OperationType::SELECT: return std::make_shared