From a65b7aeafc0ef6acf40e4a8a6d36206bf53d717c Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Wed, 14 Nov 2018 12:39:55 +0000 Subject: IVGCVSW-2092 Port LSTMCell::Eval to ArmNN * Ported Google's LSTM implementation to RefLstmFloat32Workload * Fixed the code throughout because of an error in the docs around the scratch buffer size * Updated IsLstmSupported * Added the unit tests !android-nn-driver:127 Change-Id: I5577b7e39ca52df1a7f102a9b437df6aa99520b6 --- src/backends/backendsCommon/test/LstmTestImpl.hpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/backends/backendsCommon/test/LstmTestImpl.hpp') diff --git a/src/backends/backendsCommon/test/LstmTestImpl.hpp b/src/backends/backendsCommon/test/LstmTestImpl.hpp index dfe24aa541..56f40aba84 100644 --- a/src/backends/backendsCommon/test/LstmTestImpl.hpp +++ b/src/backends/backendsCommon/test/LstmTestImpl.hpp @@ -34,7 +34,7 @@ LayerTestResult LstmNoCifgNoPeepholeNoProjectionTestImpl( armnn::TensorInfo outputStateInTensorInfo({batchSize , outputSize}, armnn::GetDataType()); - armnn::TensorInfo scratchBufferTensorInfo({batchSize, numUnits * 3}, armnn::GetDataType()); + armnn::TensorInfo scratchBufferTensorInfo({batchSize, numUnits * 4}, armnn::GetDataType()); armnn::TensorInfo cellStateOutTensorInfo({batchSize, numUnits}, armnn::GetDataType()); armnn::TensorInfo outputStateOutTensorInfo({batchSize, outputSize}, armnn::GetDataType()); armnn::TensorInfo outputTensorInfo({batchSize, outputSize}, armnn::GetDataType()); @@ -52,7 +52,7 @@ LayerTestResult LstmNoCifgNoPeepholeNoProjectionTestImpl( std::vector outputStateInVector(batchSize * outputSize, 0.f); auto outputStateInTensor = MakeTensor(outputStateInTensorInfo, outputStateInVector); - std::vector scratchBufferVector(batchSize * numUnits * 3, 0.f); + std::vector scratchBufferVector(batchSize * numUnits * 4, 0.f); auto scratchBufferTensor = MakeTensor(scratchBufferTensorInfo, scratchBufferVector); std::vector outputStateOutVector(batchSize * outputSize, 0.f); @@ -153,8 +153,8 @@ LayerTestResult LstmNoCifgNoPeepholeNoProjectionTestImpl( armnn::ScopedCpuTensorHandle inputToForgetWeightsTensor(tensorInfo8); armnn::ScopedCpuTensorHandle inputToCellWeightsTensor(tensorInfo8); armnn::ScopedCpuTensorHandle inputToOutputWeightsTensor(tensorInfo8); - armnn::ScopedCpuTensorHandle recurrentToForgetWeightsTensor(tensorInfo16); armnn::ScopedCpuTensorHandle recurrentToInputWeightsTensor(tensorInfo16); + armnn::ScopedCpuTensorHandle recurrentToForgetWeightsTensor(tensorInfo16); armnn::ScopedCpuTensorHandle recurrentToCellWeightsTensor(tensorInfo16); armnn::ScopedCpuTensorHandle recurrentToOutputWeightsTensor(tensorInfo16); armnn::ScopedCpuTensorHandle cellToInputWeightsTensor(tensorInfo4); @@ -222,11 +222,10 @@ LayerTestResult LstmNoCifgNoPeepholeNoProjectionTestImpl( LayerTestResult -LstmLayerFloat32NoCifgWithPeepholeWithProjectionTestImpl( - armnn::IWorkloadFactory& workloadFactory, - const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, - const boost::multi_array& input, - const boost::multi_array& outputExpected) +LstmLayerNoCifgWithPeepholeWithProjectionTestImpl(armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + const boost::multi_array& input, + const boost::multi_array& outputExpected) { unsigned int batchSize = 2; unsigned int outputSize = 16; @@ -237,8 +236,8 @@ LstmLayerFloat32NoCifgWithPeepholeWithProjectionTestImpl( armnn::TensorInfo cellStateInTensorInfo({batchSize , numUnits}, armnn::GetDataType()); armnn::TensorInfo outputStateInTensorInfo({batchSize , outputSize}, armnn::GetDataType()); - // Scratch buffer size without CIFG [batchSize, numUnits * 3] - armnn::TensorInfo scratchBufferTensorInfo({batchSize, numUnits * 3}, armnn::GetDataType()); + // Scratch buffer size without CIFG [batchSize, numUnits * 4] + armnn::TensorInfo scratchBufferTensorInfo({batchSize, numUnits * 4}, armnn::GetDataType()); armnn::TensorInfo cellStateOutTensorInfo({batchSize, numUnits}, armnn::GetDataType()); armnn::TensorInfo outputStateOutTensorInfo({batchSize, outputSize}, armnn::GetDataType()); armnn::TensorInfo outputTensorInfo({batchSize, outputSize}, armnn::GetDataType()); @@ -255,7 +254,7 @@ LstmLayerFloat32NoCifgWithPeepholeWithProjectionTestImpl( std::vector outputStateInVector(batchSize * outputSize, 0.f); auto outputStateInTensor = MakeTensor(outputStateInTensorInfo, outputStateInVector); - std::vector scratchBufferVector(batchSize * numUnits * 3, 0.f); + std::vector scratchBufferVector(batchSize * numUnits * 4, 0.f); auto scratchBufferTensor = MakeTensor(scratchBufferTensorInfo, scratchBufferVector); std::vector outputStateOutVector(batchSize * outputSize, 0.f); @@ -955,7 +954,7 @@ LayerTestResult LstmLayerWithCifgWithPeepholeNoProjectionTestImpl( armnn::TensorInfo outputStateInTensorInfo({batchSize, outputSize}, armnn::GetDataType()); armnn::TensorInfo cellStateInTensorInfo({batchSize, cellSize}, armnn::GetDataType()); - unsigned int scratchBufferSize = cifgEnabled ? cellSize * 4 : cellSize * 3; + unsigned int scratchBufferSize = cifgEnabled ? cellSize * 3 : cellSize * 4; armnn::TensorInfo scratchBufferTensorInfo({batchSize, scratchBufferSize}, armnn::GetDataType()); armnn::TensorInfo outputStateOutTensorInfo({batchSize, outputSize}, armnn::GetDataType()); armnn::TensorInfo cellStateOutTensorInfo({batchSize, cellSize}, armnn::GetDataType()); -- cgit v1.2.1