IVGCVSW-5538 Fix delegate DepthwiseConv2d, DIV, Reshape
authorNarumol Prangnawarat <narumol.prangnawarat@arm.com>
Fri, 20 Nov 2020 16:17:48 +0000 (16:17 +0000)
committerFrancis Murtagh <francis.murtagh@arm.com>
Fri, 20 Nov 2020 18:05:50 +0000 (18:05 +0000)
 * Correct filter shape for DepthwiseConv2d
 * Remove non-support data type
 * Allow check for flatten on Reshape

Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com>
Change-Id: Ic4be63d7c2f3a2b5e13a1530025a49464c21171b

delegate/src/Convolution.hpp
delegate/src/Redefine.hpp
delegate/src/test/ElementwiseBinaryTest.cpp
delegate/src/test/ElementwiseUnaryTest.cpp

index fed084e..2d9fdba 100644 (file)
@@ -340,6 +340,13 @@ TfLiteStatus VisitDepthwiseConv2dOperator(DelegateData& delegateData,
         biasTensorInfo = armnn::TensorInfo(armnn::TensorShape({1}), GetDataType(tfLiteInputTensor));
     }
 
+    std::vector<uint8_t> swizzledData(filterTensorInfo.GetNumBytes());
+    auto filter =
+        CreateConstTensor(&tfLiteFilterTensor,
+                          filterTensorInfo,
+                          armnn::Optional<armnn::PermutationVector&>(permutationVector),
+                          swizzledData.data());
+
     if (!delegateData.m_Network)
     {
         bool isSupported = false;
@@ -351,18 +358,13 @@ TfLiteStatus VisitDepthwiseConv2dOperator(DelegateData& delegateData,
                                    inputTensorInfo,
                                    outputTensorInfo,
                                    descriptor,
-                                   filterTensorInfo,
+                                   filter.GetInfo(),
                                    armnn::Optional<armnn::TensorInfo>(biasTensorInfo));
         return isSupported ? kTfLiteOk : kTfLiteError;
     }
 
     armnn::IConnectableLayer* layer = nullptr;
-    std::vector<uint8_t> swizzledData(filterTensorInfo.GetNumBytes());
-    auto filter =
-        CreateConstTensor(&tfLiteFilterTensor,
-                          filterTensorInfo,
-                          armnn::Optional<armnn::PermutationVector&>(permutationVector),
-                          swizzledData.data());
+
     if(biasEnabled)
     {
         auto biases =
index fb58ffd..9129576 100644 (file)
@@ -105,10 +105,13 @@ TfLiteStatus VisitReshapeOperator(DelegateData& delegateData,
             for (int i=0; i < reshapeOptions->num_dimensions; ++i)
             {
                 targetShape.push_back(reshapeOptions->shape[i]);
-                elementCounter = elementCounter * reshapeOptions->shape[i];
+                if (reshapeOptions->shape[i] > 0)
+                {
+                    elementCounter = elementCounter * reshapeOptions->shape[i];
+                }
             }
             // Check the number of elements match, otherwise fall back to using the second input tensor.
-            if (elementCounter == inputTensorInfo0.GetNumElements())
+            if (elementCounter <= inputTensorInfo0.GetNumElements())
             {
                 targetShapeFound = true;
             }
index 0ae60a2..cc447d9 100644 (file)
@@ -696,12 +696,6 @@ TEST_CASE ("DIV_Broadcast_GpuAcc_Test")
     DivBroadcastTest(backends);
 }
 
-TEST_CASE ("DIV_UINT8_GpuAcc_Test")
-{
-    std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc };
-    DivUint8Test(backends);
-}
-
 TEST_CASE ("MAX_FP32_GpuAcc_Test")
 {
     std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc };
@@ -823,12 +817,6 @@ TEST_CASE ("DIV_Broadcast_CpuAcc_Test")
     DivBroadcastTest(backends);
 }
 
-TEST_CASE ("DIV_UINT8_CpuAcc_Test")
-{
-    std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
-    DivUint8Test(backends);
-}
-
 TEST_CASE ("MAX_FP32_CpuAcc_Test")
 {
     std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
index 012ffde..3200423 100644 (file)
@@ -103,26 +103,6 @@ TEST_CASE ("Rsqrt_Float32_GpuAcc_Test")
     ElementwiseUnaryFP32Test(tflite::BuiltinOperator_RSQRT, backends, inputValues, expectedOutputValues);
 }
 
-TEST_CASE ("Sqrt_Float32_GpuAcc_Test")
-{
-    // Create the ArmNN Delegate
-    std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc };
-    // Set input data
-    std::vector<float> inputValues
-    {
-        9.0f, 4.25f, 81.9f,
-        0.1f,  0.9f,  169.0f
-    };
-    // Calculate output data
-    std::vector<float> expectedOutputValues(inputValues.size());
-    for (unsigned int i = 0; i < inputValues.size(); ++i)
-    {
-        expectedOutputValues[i] = std::sqrt(inputValues[i]);
-    }
-
-    ElementwiseUnaryFP32Test(tflite::BuiltinOperator_SQRT, backends, inputValues, expectedOutputValues);
-}
-
 } // TEST_SUITE("ElementwiseUnary_GpuAccTests")
 
 
@@ -212,28 +192,8 @@ TEST_CASE ("Rsqrt_Float32_CpuAcc_Test")
     ElementwiseUnaryFP32Test(tflite::BuiltinOperator_RSQRT, backends, inputValues, expectedOutputValues);
 }
 
-TEST_CASE ("Sqrt_Float32_CpuAcc_Test")
-{
-    std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
-    // Set input data
-    std::vector<float> inputValues
-    {
-        9.0f, 4.25f, 81.9f,
-        0.1f,  0.9f,  169.0f
-    };
-    // Calculate output data
-    std::vector<float> expectedOutputValues(inputValues.size());
-    for (unsigned int i = 0; i < inputValues.size(); ++i)
-    {
-        expectedOutputValues[i] = std::sqrt(inputValues[i]);
-    }
-
-    ElementwiseUnaryFP32Test(tflite::BuiltinOperator_SQRT, backends, inputValues, expectedOutputValues);
-}
-
 } // TEST_SUITE("ElementwiseUnary_CpuAccTests")
 
-
 TEST_SUITE("ElementwiseUnary_CpuRefTests")
 {