From eff204aa3ae75277b0cf689eed0e2073ff644ef8 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Tue, 28 Nov 2023 15:46:09 +0000 Subject: 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 Change-Id: Ia377c7a7399d0e30dc287d7217b3e3b52e1ea074 --- delegate/test/TestUtils.hpp | 54 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'delegate/test/TestUtils.hpp') 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 +#include #include 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 CaptureAvailableBackends(const std::vector& onlyTheseBackends) +{ + std::vector 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& tfLiteDelegateOutputs, std::vector& armnnDelegateOutputs, std::vector& 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 -- cgit v1.2.1