IVGCVSW-4420 Failing Unit Test Cl: Quantize layer
authorKeith Davis <keith.davis@arm.com>
Fri, 14 Feb 2020 12:22:40 +0000 (12:22 +0000)
committerKeith Davis Arm <keith.davis@arm.com>
Fri, 14 Feb 2020 12:25:39 +0000 (12:25 +0000)
 * Fix bug with missing ValidateInputsOutputs in Cl Workload
 * Renamed data type tests to be more specific
 * Future proofing

Signed-off-by: Keith Davis <keith.davis@arm.com>
Change-Id: I157acc318e40d727fcfb3f36f7f577fc87472f3d

src/backends/backendsCommon/MakeWorkloadHelper.hpp
src/backends/backendsCommon/WorkloadFactory.cpp
src/backends/backendsCommon/WorkloadUtils.cpp
src/backends/cl/ClTensorHandle.hpp
src/backends/cl/ClWorkloadFactory.cpp
src/backends/cl/test/ClLayerSupportTests.cpp
src/backends/cl/workloads/ClDequantizeWorkload.cpp
src/backends/cl/workloads/ClQuantizeWorkload.cpp
src/backends/cl/workloads/ClWorkloadUtils.hpp
src/backends/neon/workloads/NeonQuantizeWorkload.cpp

index f876c6b..250a10a 100644 (file)
@@ -59,6 +59,7 @@ std::unique_ptr<IWorkload> MakeWorkloadHelper(const QueueDescriptorType& descrip
         case DataType::QAsymmU8:
             return MakeWorkloadForType<Uint8Workload>::Func(descriptor, info, std::forward<Args>(args)...);
         case DataType::QSymmS8:
+        case DataType::QAsymmS8:
             return MakeWorkloadForType<Int8Workload>::Func(descriptor, info, std::forward<Args>(args)...);
         case DataType::Signed32:
             return MakeWorkloadForType<Int32Workload>::Func(descriptor, info, std::forward<Args>(args)...);
index 283e748..23ff70a 100644 (file)
@@ -352,6 +352,7 @@ bool IWorkloadFactory::IsLayerSupported(const BackendId& backendId,
                         break;
                     }
                     case DataType::QAsymmU8:
+                    case DataType::QAsymmS8:
                     case DataType::QSymmS8:
                     case DataType::QSymmS16:
                     {
index 69a6291..3b3959b 100644 (file)
@@ -166,6 +166,7 @@ armnn::ConstTensor ConvertWeightTensorFromArmnnToAcl(const ConstCpuTensorHandle*
                 weightPermuted =
                     ReorderWeightChannelsForAcl<half_float::half>(weightPermuted, dataLayout, permuteBuffer);
                 break;
+            case DataType::QAsymmS8:
             case DataType::QAsymmU8:
                 weightPermuted = ReorderWeightChannelsForAcl<uint8_t>(weightPermuted, dataLayout, permuteBuffer);
                 break;
index cf2b44a..1830d18 100644 (file)
@@ -100,6 +100,11 @@ private:
                 armcomputetensorutils::CopyArmComputeITensorData(this->GetTensor(),
                                                                  static_cast<uint8_t*>(memory));
                 break;
+            case arm_compute::DataType::QSYMM8_PER_CHANNEL:
+            case arm_compute::DataType::QASYMM8_SIGNED:
+                armcomputetensorutils::CopyArmComputeITensorData(this->GetTensor(),
+                                                                 static_cast<int8_t*>(memory));
+                break;
             case arm_compute::DataType::F16:
                 armcomputetensorutils::CopyArmComputeITensorData(this->GetTensor(),
                                                                  static_cast<armnn::Half*>(memory));
@@ -141,6 +146,11 @@ private:
                                                                  this->GetTensor());
                 break;
             case arm_compute::DataType::S16:
+            case arm_compute::DataType::QSYMM8_PER_CHANNEL:
+            case arm_compute::DataType::QASYMM8_SIGNED:
+                armcomputetensorutils::CopyArmComputeITensorData(static_cast<const int8_t*>(memory),
+                                                                 this->GetTensor());
+                break;
             case arm_compute::DataType::QSYMM16:
                 armcomputetensorutils::CopyArmComputeITensorData(static_cast<const int16_t*>(memory),
                                                                  this->GetTensor());
@@ -224,6 +234,11 @@ private:
                 armcomputetensorutils::CopyArmComputeITensorData(this->GetTensor(),
                                                                  static_cast<armnn::Half*>(memory));
                 break;
+            case arm_compute::DataType::QSYMM8_PER_CHANNEL:
+            case arm_compute::DataType::QASYMM8_SIGNED:
+            armcomputetensorutils::CopyArmComputeITensorData(this->GetTensor(),
+                                                             static_cast<int8_t*>(memory));
+                break;
             case arm_compute::DataType::S16:
             case arm_compute::DataType::QSYMM16:
                 armcomputetensorutils::CopyArmComputeITensorData(this->GetTensor(),
@@ -260,6 +275,11 @@ private:
                 armcomputetensorutils::CopyArmComputeITensorData(static_cast<const armnn::Half*>(memory),
                                                                  this->GetTensor());
                 break;
+            case arm_compute::DataType::QSYMM8_PER_CHANNEL:
+            case arm_compute::DataType::QASYMM8_SIGNED:
+                armcomputetensorutils::CopyArmComputeITensorData(static_cast<const int8_t*>(memory),
+                                                                 this->GetTensor());
+                break;
             case arm_compute::DataType::S16:
             case arm_compute::DataType::QSYMM16:
                 armcomputetensorutils::CopyArmComputeITensorData(static_cast<const int16_t*>(memory),
index 0440aac..4bb2e2a 100644 (file)
@@ -438,7 +438,7 @@ std::unique_ptr<IWorkload> ClWorkloadFactory::CreatePrelu(const PreluQueueDescri
 std::unique_ptr<IWorkload> ClWorkloadFactory::CreateQuantize(const QuantizeQueueDescriptor& descriptor,
                                                              const WorkloadInfo& info) const
 {
-    return MakeWorkload<ClQuantizeWorkload, NullWorkload>(descriptor, info);
+    return MakeWorkload<ClQuantizeWorkload>(descriptor, info);
 }
 
 std::unique_ptr<IWorkload> ClWorkloadFactory::CreateQuantizedLstm(const QuantizedLstmQueueDescriptor& descriptor,
index 8d10375..33a2912 100644 (file)
@@ -36,14 +36,21 @@ BOOST_FIXTURE_TEST_CASE(IsLayerSupportedFloat32Cl, ClContextControlFixture)
     IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::Float32>(&factory);
 }
 
-BOOST_FIXTURE_TEST_CASE(IsLayerSupportedUint8Cl, ClContextControlFixture)
+BOOST_FIXTURE_TEST_CASE(IsLayerSupportedQAsymmU8Cl, ClContextControlFixture)
 {
     armnn::ClWorkloadFactory factory =
         ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager());
     IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::QAsymmU8>(&factory);
 }
 
-BOOST_FIXTURE_TEST_CASE(IsLayerSupportedInt8Cl, ClContextControlFixture)
+BOOST_FIXTURE_TEST_CASE(IsLayerSupportedQAsymmS8Cl, ClContextControlFixture)
+{
+    armnn::ClWorkloadFactory factory =
+        ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager());
+    IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::QAsymmS8>(&factory);
+}
+
+BOOST_FIXTURE_TEST_CASE(IsLayerSupportedQSymmS8Cl, ClContextControlFixture)
 {
     armnn::ClWorkloadFactory factory =
         ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager());
index 67a555a..eca795d 100644 (file)
@@ -32,6 +32,8 @@ ClDequantizeWorkload::ClDequantizeWorkload(const DequantizeQueueDescriptor& desc
                                            const WorkloadInfo& workloadInfo)
                                            : BaseWorkload<DequantizeQueueDescriptor>(descriptor, workloadInfo)
 {
+    m_Data.ValidateInputsOutputs("ClDequantizeWorkload", 1, 1);
+
     arm_compute::ICLTensor& input = boost::polymorphic_pointer_downcast<IClTensorHandle>(
             m_Data.m_Inputs[0])->GetTensor();
 
index 230e346..263065a 100644 (file)
@@ -32,6 +32,8 @@ arm_compute::Status ClQuantizeWorkloadValidate(const TensorInfo& input,
 ClQuantizeWorkload::ClQuantizeWorkload(const QuantizeQueueDescriptor& descriptor, const WorkloadInfo& info)
     : BaseWorkload<QuantizeQueueDescriptor>(descriptor, info)
 {
+    m_Data.ValidateInputsOutputs("ClQuantizeWorkload", 1, 1);
+
     arm_compute::ICLTensor& input  = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
     arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
 
index d3c6df5..b4bcc1c 100644 (file)
@@ -101,6 +101,7 @@ inline void InitializeArmComputeClTensorData(arm_compute::CLTensor& clTensor,
         case DataType::Float32:
             CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<float>());
             break;
+        case DataType::QAsymmS8:
         case DataType::QAsymmU8:
             CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<uint8_t>());
             break;
index cb8393b..4f3ea2c 100644 (file)
@@ -28,6 +28,8 @@ NeonQuantizeWorkload::NeonQuantizeWorkload(const QuantizeQueueDescriptor& descri
      const WorkloadInfo& workloadInfo)
      : BaseWorkload<QuantizeQueueDescriptor>(descriptor, workloadInfo)
 {
+    m_Data.ValidateInputsOutputs("NeonQuantizeWorkload", 1, 1);
+
     arm_compute::ITensor& input = boost::polymorphic_pointer_downcast<IAclTensorHandle>(
                                                                       m_Data.m_Inputs[0])->GetTensor();
     arm_compute::ITensor& output = boost::polymorphic_pointer_downcast<IAclTensorHandle>(