diff options
author | Colm Donelan <colm.donelan@arm.com> | 2023-11-28 15:46:09 +0000 |
---|---|---|
committer | Colm Donelan <colm.donelan@arm.com> | 2023-12-18 10:27:21 +0000 |
commit | eff204aa3ae75277b0cf689eed0e2073ff644ef8 (patch) | |
tree | cc222af9c397947f240a1554414fd2ac4c5cf636 /delegate/test/TestUtils.hpp | |
parent | 7790dc6531034778d92ba264fd61174bcff7051e (diff) | |
download | armnn-eff204aa3ae75277b0cf689eed0e2073ff644ef8.tar.gz |
IVGCVSW-7675 Rework DelegateUnitTests so backends are subcases.
The intent of this change is to remove the per backend test cases in
the delegate unit tests. They will be replaced by using DocTest
SUBCASES. The sub cases are paramaterized by the available backends.
The list of available backends are determined by the compilation flags.
Signed-off-by: Colm Donelan <colm.donelan@arm.com>
Change-Id: Ia377c7a7399d0e30dc287d7217b3e3b52e1ea074
Diffstat (limited to 'delegate/test/TestUtils.hpp')
-rw-r--r-- | delegate/test/TestUtils.hpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/delegate/test/TestUtils.hpp b/delegate/test/TestUtils.hpp index ba81cd8d56..0932f229cc 100644 --- a/delegate/test/TestUtils.hpp +++ b/delegate/test/TestUtils.hpp @@ -10,10 +10,60 @@ #include <doctest/doctest.h> +#include <armnn/BackendId.hpp> #include <half/half.hpp> using Half = half_float::half; +namespace +{ +/** + * Based on the compilation options capture subcases for the available backends. If "onlyTheseBackends" is NOT empty + * then we'll ignore any backend NOT listed in it. + * + * @param onlyTheseBackends limit the number of backends considered for sub casing. If empty all are considered. + * @return vector of backends that have been captured for sub casing. + */ +std::vector<armnn::BackendId> CaptureAvailableBackends(const std::vector<armnn::BackendId>& onlyTheseBackends) +{ + std::vector<armnn::BackendId> availableBackends; +#if defined(ARMNNREF_ENABLED) + // Careful logic here. An empty onlyTheseBackends means we always evaluate. + if (onlyTheseBackends.empty() || (std::find(onlyTheseBackends.begin(), onlyTheseBackends.end(), + armnn::Compute::CpuRef) != onlyTheseBackends.end())) + { + SUBCASE("CpuRef") + { + availableBackends.push_back({ armnn::Compute::CpuRef }); + } + } +#endif +#if defined(ARMCOMPUTENEON_ENABLED) + // Careful logic here. An empty onlyTheseBackends means we always evaluate. + if (onlyTheseBackends.empty() || (std::find(onlyTheseBackends.begin(), onlyTheseBackends.end(), + armnn::Compute::CpuAcc) != onlyTheseBackends.end())) + { + SUBCASE("CpuAcc") + { + availableBackends.push_back({ armnn::Compute::CpuAcc }); + } + } +#endif +#if defined(ARMCOMPUTECL_ENABLED) + if (onlyTheseBackends.empty() || (std::find(onlyTheseBackends.begin(), onlyTheseBackends.end(), + armnn::Compute::GpuAcc) != onlyTheseBackends.end())) + { + SUBCASE("GpuAcc") + { + availableBackends.push_back({ armnn::Compute::GpuAcc }); + } + } +#endif + CAPTURE(availableBackends); + return availableBackends; +} + +} // namespace namespace armnnDelegate { @@ -65,9 +115,9 @@ void CompareOutputData(std::vector<T>& tfLiteDelegateOutputs, std::vector<T>& armnnDelegateOutputs, std::vector<T>& expectedOutputValues) { - armnnDelegate::CompareData(expectedOutputValues.data(), armnnDelegateOutputs.data(), expectedOutputValues.size()); + armnnDelegate::CompareData(expectedOutputValues.data(), armnnDelegateOutputs.data(), expectedOutputValues.size()); armnnDelegate::CompareData(tfLiteDelegateOutputs.data(), expectedOutputValues.data(), expectedOutputValues.size()); armnnDelegate::CompareData(tfLiteDelegateOutputs.data(), armnnDelegateOutputs.data(), expectedOutputValues.size()); } -} // namespace armnnDelegate +} // namespace armnnDelegate |