diff options
author | Matthew Jackson <matthew.jackson@arm.com> | 2019-09-12 09:08:23 +0100 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-09-12 15:28:01 +0000 |
commit | 9bff14458f9950a5d31b9523c62c0bbf79a65fcf (patch) | |
tree | 8252812da63458e38b704a3abba3e1d5a35e1bf2 /src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp | |
parent | 1e0466c4ab26e82abed7f8f263dfe6a2a543cc1a (diff) | |
download | armnn-9bff14458f9950a5d31b9523c62c0bbf79a65fcf.tar.gz |
IVGCVSW-3857 Add Reference FP16 workload support to remaining layers
* Adds Reference FP16 support and unit tests for layers not already supported
!referencetests:202156
Signed-off-by: Matthew Jackson <matthew.jackson@arm.com>
Change-Id: I6fc9b9ce2809e163f72e27e877025c8fb85d9fbe
Diffstat (limited to 'src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp')
-rw-r--r-- | src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp | 100 |
1 files changed, 98 insertions, 2 deletions
diff --git a/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp index d8f87e15de..ef430883d4 100644 --- a/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp @@ -198,7 +198,7 @@ LayerTestResult<T,4> BatchNormTestNhwcImpl( } // anonymous namespace -LayerTestResult<float, 4> BatchNormFloatTest( +LayerTestResult<float, 4> BatchNormFloat32Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { @@ -244,7 +244,7 @@ LayerTestResult<float, 4> BatchNormFloatTest( armnn::DataLayout::NCHW); } -LayerTestResult<float, 4> BatchNormFloatNhwcTest( +LayerTestResult<float, 4> BatchNormFloat32NhwcTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { @@ -294,6 +294,102 @@ LayerTestResult<float, 4> BatchNormFloatNhwcTest( armnn::DataLayout::NHWC); } +LayerTestResult<armnn::Half, 4> BatchNormFloat16Test( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) +{ + // BatchSize: 1 + // Channels: 2 + // Height: 3 + // Width: 2 + + const armnn::TensorShape inputOutputShape{ 1, 2, 3, 2 }; + std::vector<float> inputValues + { + // Batch 0, Channel 0, Height (3) x Width (2) + 1.f, 4.f, + 4.f, 2.f, + 1.f, 6.f, + + // Batch 0, Channel 1, Height (3) x Width (2) + 1.f, 1.f, + 4.f, 1.f, + -2.f, 4.f + }; + std::vector<float> expectedOutputValues + { + // Batch 0, Channel 0, Height (3) x Width (2) + 1.f, 4.f, + 4.f, 2.f, + 1.f, 6.f, + + // Batch 0, Channel 1, Height (3) x Width (2) + 3.f, 3.f, + 4.f, 3.f, + 2.f, 4.f + }; + + return BatchNormTestImpl<armnn::DataType::Float16>( + workloadFactory, + memoryManager, + inputOutputShape, + inputValues, + expectedOutputValues, + 0.f, + 0, + armnn::DataLayout::NCHW); +} + +LayerTestResult<armnn::Half, 4> BatchNormFloat16NhwcTest( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) +{ + // BatchSize: 1 + // Height: 3 + // Width: 2 + // Channels: 2 + + const armnn::TensorShape inputOutputShape{ 1, 3, 2, 2 }; + std::vector<float> inputValues + { + // Batch 0, Height 0, Width (2) x Channel (2) + 1.f, 1.f, + 4.f, 1.f, + + // Batch 0, Height 1, Width (2) x Channel (2) + 4.f, 4.f, + 2.f, 1.f, + + // Batch 0, Height 2, Width (2) x Channel (2) + 1.f, -2.f, + 6.f, 4.f + }; + std::vector<float> expectedOutputValues + { + // Batch 0, Height 0, Width (2) x Channel (2) + 1.f, 3.f, + 4.f, 3.f, + + // Batch 0, Height 1, Width (2) x Channel (2) + 4.f, 4.f, + 2.f, 3.f, + + // Batch 0, Height 2, Width (2) x Channel (2) + 1.f, 2.f, + 6.f, 4.f + }; + + return BatchNormTestImpl<armnn::DataType::Float16>( + workloadFactory, + memoryManager, + inputOutputShape, + inputValues, + expectedOutputValues, + 0.f, + 0, + armnn::DataLayout::NHWC); +} + LayerTestResult<uint8_t, 4> BatchNormUint8Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |