aboutsummaryrefslogtreecommitdiff
path: root/src/backends/cl/test
diff options
context:
space:
mode:
authorFerran Balaguer <ferran.balaguer@arm.com>2019-08-01 09:58:08 +0100
committerÁron Virginás-Tar <aron.virginas-tar@arm.com>2019-08-05 13:08:36 +0000
commit737d9ff58b348b11234b6c2363390607d576177d (patch)
treef0ab993791799fc5110ee25ed9612fb8ed6e3e99 /src/backends/cl/test
parent651aafec6235ddbc1177229dedcdd21ffad01616 (diff)
downloadarmnn-737d9ff58b348b11234b6c2363390607d576177d.tar.gz
IVGCVSW-3342 Add CL backend support for Quantized_LSTM (16bit cell state)
!android-nn-driver:1685 Signed-off-by: Ferran Balaguer <ferran.balaguer@arm.com> Signed-off-by: Matthew Bentham <matthew.bentham@arm.com> Change-Id: I17278562f72d4b77e22c3af25bf7199b9150a765
Diffstat (limited to 'src/backends/cl/test')
-rw-r--r--src/backends/cl/test/ClCreateWorkloadTests.cpp41
-rw-r--r--src/backends/cl/test/ClLayerTests.cpp2
2 files changed, 43 insertions, 0 deletions
diff --git a/src/backends/cl/test/ClCreateWorkloadTests.cpp b/src/backends/cl/test/ClCreateWorkloadTests.cpp
index f453ccc9fd..bb36504214 100644
--- a/src/backends/cl/test/ClCreateWorkloadTests.cpp
+++ b/src/backends/cl/test/ClCreateWorkloadTests.cpp
@@ -9,6 +9,7 @@
#include <backendsCommon/MemCopyWorkload.hpp>
#include <aclCommon/test/CreateWorkloadClNeon.hpp>
+#include <aclCommon/ArmComputeTensorUtils.hpp>
#include <cl/ClTensorHandle.hpp>
#include <cl/ClWorkloadFactory.hpp>
@@ -974,4 +975,44 @@ BOOST_AUTO_TEST_CASE(CreateStackUint8Workload)
ClCreateStackWorkloadTest<armnn::DataType::QuantisedAsymm8>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2);
}
+template <typename QuantizedLstmWorkloadType>
+static void ClCreateQuantizedLstmWorkloadTest()
+{
+ using namespace armnn::armcomputetensorutils;
+ using boost::polymorphic_downcast;
+
+ Graph graph;
+ ClWorkloadFactory factory =
+ ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager());
+
+ auto workload = CreateQuantizedLstmWorkloadTest<QuantizedLstmWorkloadType>(factory, graph);
+
+ QuantizedLstmQueueDescriptor queueDescriptor = workload->GetData();
+
+ IAclTensorHandle* inputHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]);
+ BOOST_TEST((inputHandle->GetShape() == TensorShape({2, 2})));
+ BOOST_TEST((inputHandle->GetDataType() == arm_compute::DataType::QASYMM8));
+
+ IAclTensorHandle* cellStateInHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[1]);
+ BOOST_TEST((cellStateInHandle->GetShape() == TensorShape({2, 4})));
+ BOOST_TEST((cellStateInHandle->GetDataType() == arm_compute::DataType::QSYMM16));
+
+ IAclTensorHandle* outputStateInHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[2]);
+ BOOST_TEST((outputStateInHandle->GetShape() == TensorShape({2, 4})));
+ BOOST_TEST((outputStateInHandle->GetDataType() == arm_compute::DataType::QASYMM8));
+
+ IAclTensorHandle* cellStateOutHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]);
+ BOOST_TEST((cellStateOutHandle->GetShape() == TensorShape({2, 4})));
+ BOOST_TEST((cellStateOutHandle->GetDataType() == arm_compute::DataType::QSYMM16));
+
+ IAclTensorHandle* outputStateOutHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[1]);
+ BOOST_TEST((outputStateOutHandle->GetShape() == TensorShape({2, 4})));
+ BOOST_TEST((outputStateOutHandle->GetDataType() == arm_compute::DataType::QASYMM8));
+}
+
+BOOST_AUTO_TEST_CASE(CreateQuantizedLstmWorkload)
+{
+ ClCreateQuantizedLstmWorkloadTest<ClQuantizedLstmWorkload>();
+}
+
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/backends/cl/test/ClLayerTests.cpp b/src/backends/cl/test/ClLayerTests.cpp
index dd4c16edf4..c9114b9ac4 100644
--- a/src/backends/cl/test/ClLayerTests.cpp
+++ b/src/backends/cl/test/ClLayerTests.cpp
@@ -401,6 +401,8 @@ ARMNN_AUTO_TEST_CASE(LstmLayerFloat32NoCifgWithPeepholeWithProjection,
ARMNN_AUTO_TEST_CASE(LstmLayerFloat32NoCifgWithPeepholeWithProjectionWithLayerNorm,
LstmLayerFloat32NoCifgWithPeepholeWithProjectionWithLayerNormTest)
+ARMNN_AUTO_TEST_CASE(QuantizedLstm, QuantizedLstmTest)
+
// Convert from Float16 to Float32
ARMNN_AUTO_TEST_CASE(SimpleConvertFp16ToFp32, SimpleConvertFp16ToFp32Test)
// Convert from Float32 to Float16