diff options
author | Narumol Prangnawarat <narumol.prangnawarat@arm.com> | 2020-11-20 14:50:54 +0000 |
---|---|---|
committer | Francis Murtagh <francis.murtagh@arm.com> | 2020-11-20 17:35:57 +0000 |
commit | 55518ca7faaf6c2b0cd567afe9fb39d529a10150 (patch) | |
tree | eed61cf0055788a96ab2dc4b16f16d944d2d7ef1 /delegate/src/test | |
parent | 63e75dce4d685521f53b26b987d20d11829a4126 (diff) | |
download | armnn-55518ca7faaf6c2b0cd567afe9fb39d529a10150.tar.gz |
IVGCVSW-5544 Fix FullyConnected Delegate tests
* Correct input shape
Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com>
Change-Id: I9d1fe4c8ef32a9dfba7f7fdd6af314e9a522fce8
Diffstat (limited to 'delegate/src/test')
-rw-r--r-- | delegate/src/test/FullyConnectedTest.cpp | 99 | ||||
-rw-r--r-- | delegate/src/test/FullyConnectedTestHelper.hpp | 2 |
2 files changed, 65 insertions, 36 deletions
diff --git a/delegate/src/test/FullyConnectedTest.cpp b/delegate/src/test/FullyConnectedTest.cpp index 1d33381d6e..018f7f5190 100644 --- a/delegate/src/test/FullyConnectedTest.cpp +++ b/delegate/src/test/FullyConnectedTest.cpp @@ -8,9 +8,6 @@ namespace { -TEST_SUITE("FullyConnectedTest") -{ - void FullyConnectedFp32Test(std::vector<armnn::BackendId>& backends) { std::vector<int32_t> inputTensorShape { 1, 4, 1, 1 }; @@ -61,68 +58,100 @@ void FullyConnectedActicationTest(std::vector<armnn::BackendId>& backends) weightsData); } -void FullyConnectedUint8Test(std::vector<armnn::BackendId>& backends) +void FullyConnectedInt8Test(std::vector<armnn::BackendId>& backends) { std::vector<int32_t> inputTensorShape { 1, 4, 2, 1 }; std::vector<int32_t> weightsTensorShape { 1, 4 }; std::vector<int32_t> biasTensorShape { 1 }; std::vector<int32_t> outputTensorShape { 2, 1 }; - std::vector<uint8_t> inputValues = { 1, 2, 3, 4, 10, 20, 30, 40 }; - std::vector<uint8_t> weightsData = { 2, 3, 4, 5 }; + std::vector<int8_t> inputValues = { 1, 2, 3, 4, 5, 10, 15, 20 }; + std::vector<int8_t> weightsData = { 2, 3, 4, 5 }; - std::vector<uint8_t> expectedOutputValues = { (40 + 10) / 2, (400 + 10) / 2 }; + std::vector<int8_t> expectedOutputValues = { 25, 105 }; // (40 + 10) / 2, (200 + 10) / 2 // bias is set std::vector<int32_t> biasData = { 10 } in the model // input and weights quantization scale 1.0f and offset 0 in the model // output quantization scale 2.0f and offset 0 in the model - FullyConnectedTest<uint8_t>(backends, - ::tflite::TensorType_UINT8, - tflite::ActivationFunctionType_NONE, - inputTensorShape, - weightsTensorShape, - biasTensorShape, - outputTensorShape, - inputValues, - expectedOutputValues, - weightsData); + FullyConnectedTest<int8_t>(backends, + ::tflite::TensorType_INT8, + tflite::ActivationFunctionType_NONE, + inputTensorShape, + weightsTensorShape, + biasTensorShape, + outputTensorShape, + inputValues, + expectedOutputValues, + weightsData); } -TEST_CASE ("FULLY_CONNECTED_FP32_GpuAcc_Test") +TEST_SUITE("FullyConnected_GpuAccTests") +{ + +TEST_CASE ("FullyConnected_FP32_GpuAcc_Test") { - std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc, - armnn::Compute::CpuRef }; + std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc }; FullyConnectedFp32Test(backends); } -TEST_CASE ("FULLY_CONNECTED_FP32_CpuAcc_Test") +TEST_CASE ("FullyConnected_Int8_GpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc }; + FullyConnectedInt8Test(backends); +} + +TEST_CASE ("FullyConnected_Activation_GpuAcc_Test") { - std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc, - armnn::Compute::CpuRef }; + std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc }; + FullyConnectedActicationTest(backends); +} + +} // End of TEST_SUITE("FullyConnected_GpuAccTests") + +TEST_SUITE("FullyConnected_CpuAccTests") +{ + +TEST_CASE ("FullyConnected_FP32_CpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc }; FullyConnectedFp32Test(backends); } -TEST_CASE ("FULLY_CONNECTED_UINT8_GpuAcc_Test") +TEST_CASE ("FullyConnected_Int8_CpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc }; + FullyConnectedInt8Test(backends); +} + +TEST_CASE ("FullyConnected_Activation_CpuAcc_Test") { - std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc, - armnn::Compute::CpuRef }; - FullyConnectedUint8Test(backends); + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc }; + FullyConnectedActicationTest(backends); +} + +} // End of TEST_SUITE("FullyConnected_CpuAccTests") + +TEST_SUITE("FullyConnected_CpuRefTests") +{ + +TEST_CASE ("FullyConnected_FP32_CpuRef_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; + FullyConnectedFp32Test(backends); } -TEST_CASE ("FULLY_CONNECTED_UINT8_CpuAcc_Test") +TEST_CASE ("FullyConnected_Int8_CpuRef_Test") { - std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc, - armnn::Compute::CpuRef }; - FullyConnectedUint8Test(backends); + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; + FullyConnectedInt8Test(backends); } -TEST_CASE ("FULLY_CONNECTED_Activation_GpuAcc_Test") +TEST_CASE ("FullyConnected_Activation_CpuRef_Test") { - std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc, - armnn::Compute::CpuRef }; + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; FullyConnectedActicationTest(backends); } -} // End of TEST_SUITE("FullyConnectedTest") +} // End of TEST_SUITE("FullyConnected_CpuRefTests") } // anonymous namespace
\ No newline at end of file diff --git a/delegate/src/test/FullyConnectedTestHelper.hpp b/delegate/src/test/FullyConnectedTestHelper.hpp index 4eed9580f1..4b30424d86 100644 --- a/delegate/src/test/FullyConnectedTestHelper.hpp +++ b/delegate/src/test/FullyConnectedTestHelper.hpp @@ -41,7 +41,7 @@ std::vector<char> CreateFullyConnectedTfLiteModel(tflite::TensorType tensorType, sizeof(T) * weightsData.size())); auto biasTensorType = ::tflite::TensorType_FLOAT32; - if (tensorType == ::tflite::TensorType_UINT8) + if (tensorType == ::tflite::TensorType_INT8) { biasTensorType = ::tflite::TensorType_INT32; std::vector<int32_t> biasData = { 10 }; |