diff options
author | Teresa Charlin <teresa.charlinreyes@arm.com> | 2023-03-14 12:10:28 +0000 |
---|---|---|
committer | Teresa Charlin <teresa.charlinreyes@arm.com> | 2023-03-28 11:41:55 +0100 |
commit | ad1b3d7518429e2d16a2695d9b0bbf81b6565ac9 (patch) | |
tree | a5b8e1ad68a2437f007338f0b6195ca5ed2bddc3 /delegate/test/SpaceDepthTest.cpp | |
parent | 9cb3466b677a1048b8abb24661e92c4c83fdda04 (diff) | |
download | armnn-ad1b3d7518429e2d16a2695d9b0bbf81b6565ac9.tar.gz |
IVGCVSW-7555 Restructure Delegate
* New folders created:
* common is for common code where TfLite API is not used
* classic is for existing delegate implementations
* opaque is for new opaque delegate implementation,
* tests is for shared between existing Delegate and Opaque Delegate which have test utils to work which delegate to use.
* Existing delegate is built to libarmnnDelegate.so and opaque delegate is built as libarmnnOpaqueDelegate.so
* Opaque structure is introduced but no API is added yet.
* CmakeList.txt and delegate/CMakeList.txt have been modified and 2 new CmakeList.txt added
* Rename BUILD_ARMNN_TFLITE_DELEGATE as BUILD_CLASSIC_DELEGATE
* Rename BUILD_ARMNN_TFLITE_OPAQUE_DELEGATE as BUILD_OPAQUE_DELEGATE
Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Change-Id: Ib682b9ad0ac8d8acdc4ec6d9099bb0008a9fe8ed
Diffstat (limited to 'delegate/test/SpaceDepthTest.cpp')
-rw-r--r-- | delegate/test/SpaceDepthTest.cpp | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/delegate/test/SpaceDepthTest.cpp b/delegate/test/SpaceDepthTest.cpp new file mode 100644 index 0000000000..8a8bbaeccb --- /dev/null +++ b/delegate/test/SpaceDepthTest.cpp @@ -0,0 +1,207 @@ +// +// Copyright © 2021, 2023 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "SpaceDepthTestHelper.hpp" + +#include <armnn_delegate.hpp> + +#include <flatbuffers/flatbuffers.h> +#include <schema_generated.h> + +#include <doctest/doctest.h> + +namespace armnnDelegate +{ + +void DepthToSpaceFp32Test(std::vector<armnn::BackendId>& backends, int blockSize) +{ + // Set input data + std::vector<int32_t> inputShape { 1, 2, 2, 4 }; + std::vector<int32_t> outputShape { 1, 4, 4, 1 }; + + std::vector<float> inputValues = { 1.f, 2.f, 3.f, 4.f, + 5.f, 6.f, 7.f, 8.f, + 9.f, 10.f, 11.f, 12.f, + 13.f, 14.f, 15.f, 16.f }; + + std::vector<float> expectedOutputValues = { 1.f, 2.f, 5.f, 6.f, + 3.f, 4.f, 7.f, 8.f, + 9.f, 10.f, 13.f, 14.f, + 11.f, 12.f, 15.f, 16.f }; + + SpaceDepthTest<float>(tflite::BuiltinOperator_DEPTH_TO_SPACE, + ::tflite::TensorType_FLOAT32, + backends, + inputShape, + outputShape, + inputValues, + expectedOutputValues, + blockSize); +} + +void DepthToSpaceUint8Test(std::vector<armnn::BackendId>& backends, int blockSize) +{ + // Set input data + std::vector<int32_t> inputShape { 2, 1, 1, 4 }; + std::vector<int32_t> outputShape { 2, 2, 2, 1 }; + + std::vector<uint8_t> inputValues = { 1, 2, 3, 4, + 5, 6, 7, 8 }; + + std::vector<uint8_t> expectedOutputValues = { 1, 2, 3, 4, + 5, 6, 7, 8 }; + + SpaceDepthTest<uint8_t>(tflite::BuiltinOperator_DEPTH_TO_SPACE, + ::tflite::TensorType_UINT8, + backends, + inputShape, + outputShape, + inputValues, + expectedOutputValues, + blockSize); +} + +void SpaceToDepthFp32Test(std::vector<armnn::BackendId>& backends, int blockSize) +{ + // Set input data + std::vector<int32_t> inputShape { 1, 2, 2, 2 }; + std::vector<int32_t> outputShape { 1, 1, 1, 8 }; + + std::vector<float> inputValues = { 1.4f, 2.3f, 3.2f, 4.1f, 5.4f, 6.3f, 7.2f, 8.1f }; + std::vector<float> expectedOutputValues = { 1.4f, 2.3f, 3.2f, 4.1f, 5.4f, 6.3f, 7.2f, 8.1f }; + + SpaceDepthTest<float>(tflite::BuiltinOperator_SPACE_TO_DEPTH, + ::tflite::TensorType_FLOAT32, + backends, + inputShape, + outputShape, + inputValues, + expectedOutputValues, + blockSize); +} + +void SpaceToDepthUint8Test(std::vector<armnn::BackendId>& backends, int blockSize) +{ + // Set input data + std::vector<int32_t> inputShape { 1, 2, 2, 1 }; + std::vector<int32_t> outputShape { 1, 1, 1, 4 }; + + std::vector<uint8_t> inputValues = { 1, 2, 3, 2 }; + std::vector<uint8_t> expectedOutputValues = { 1, 2, 3, 2 }; + + SpaceDepthTest<uint8_t>(tflite::BuiltinOperator_SPACE_TO_DEPTH, + ::tflite::TensorType_UINT8, + backends, + inputShape, + outputShape, + inputValues, + expectedOutputValues, + blockSize); +} + +TEST_SUITE("DepthToSpace_CpuRefTests") +{ + +TEST_CASE ("DepthToSpaceFp32Test_CpuRef_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; + DepthToSpaceFp32Test(backends, 2); +} + +TEST_CASE ("DepthToSpaceUint8Test_CpuRef_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; + DepthToSpaceUint8Test(backends, 2); +} + +} // TEST_SUITE("DepthToSpace_CpuRefTests") + + +TEST_SUITE("DepthToSpace_CpuAccTests") +{ + +TEST_CASE ("DepthToSpaceFp32Test_CpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc }; + DepthToSpaceFp32Test(backends, 2); +} + +TEST_CASE ("DepthToSpaceUint8Test_CpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc }; + DepthToSpaceUint8Test(backends, 2); +} + +} // TEST_SUITE("DepthToSpace_CpuAccTests") + +TEST_SUITE("DepthToSpace_GpuAccTests") +{ + +TEST_CASE ("DepthToSpaceFp32Test_GpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc }; + DepthToSpaceFp32Test(backends, 2); +} + +TEST_CASE ("DepthToSpaceUint8Test_GpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc }; + DepthToSpaceUint8Test(backends, 2); +} + +} // TEST_SUITE("DepthToSpace_GpuAccTests") + +TEST_SUITE("SpaceToDepth_CpuRefTests") +{ + +TEST_CASE ("SpaceToDepthFp32Test_CpuRef_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; + SpaceToDepthFp32Test(backends, 2); +} + +TEST_CASE ("SpaceToDepthUint8Test_CpuRef_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; + SpaceToDepthUint8Test(backends, 2); +} + +} // TEST_SUITE("SpaceToDepth_CpuRefTests") + +TEST_SUITE("SpaceToDepth_CpuAccTests") +{ + +TEST_CASE ("SpaceToDepthFp32Test_CpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc }; + SpaceToDepthFp32Test(backends, 2); +} + +TEST_CASE ("SpaceToDepthUint8Test_CpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc }; + SpaceToDepthUint8Test(backends, 2); +} + +} // TEST_SUITE("SpaceToDepth_CpuAccTests") + +TEST_SUITE("SpaceToDepth_GpuAccTests") +{ + +TEST_CASE ("SpaceToDepthFp32Test_GpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc }; + SpaceToDepthFp32Test(backends, 2); +} + +TEST_CASE ("SpaceToDepthUint8Test_GpuAcc_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc }; + SpaceToDepthUint8Test(backends, 2); +} + +} // TEST_SUITE("SpaceToDepth_GpuAccTests") + +} // namespace armnnDelegate |