aboutsummaryrefslogtreecommitdiff
path: root/test/1.3
diff options
context:
space:
mode:
authorSadik Armagan <sadik.armagan@arm.com>2021-05-26 15:40:53 +0100
committerSadik Armagan <sadik.armagan@arm.com>2021-06-09 14:50:34 +0000
commit9150bff63a690caa743c471943afe509ebed1044 (patch)
treef98047d0a3a0e6cf06a4f34e0270a3cc7e3ee8bd /test/1.3
parent07648f41d8b1fe9f532fa9c7e8e96a8e3651e59d (diff)
downloadandroid-nn-driver-9150bff63a690caa743c471943afe509ebed1044.tar.gz
IVGCVSW-4618 'Transition Units Test Suites'
* Used doctest in android-nn-driver unit tests. Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Change-Id: I9b5d4dfd77d53c7ebee7f8c43628a1d6ff74d1a3
Diffstat (limited to 'test/1.3')
-rw-r--r--test/1.3/QLstm.cpp73
-rw-r--r--test/1.3/QosTests.cpp26
2 files changed, 39 insertions, 60 deletions
diff --git a/test/1.3/QLstm.cpp b/test/1.3/QLstm.cpp
index 27e52a60..82acba6e 100644
--- a/test/1.3/QLstm.cpp
+++ b/test/1.3/QLstm.cpp
@@ -10,14 +10,10 @@
#include <armnn/utility/IgnoreUnused.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/test/data/test_case.hpp>
-#include <boost/math/special_functions/relative_difference.hpp>
+#include <doctest/doctest.h>
#include <array>
-BOOST_AUTO_TEST_SUITE(QLSTMTests)
-
using ArmnnDriver = armnn_driver::ArmnnDriver;
using DriverOptions = armnn_driver::DriverOptions;
@@ -26,6 +22,8 @@ using namespace android::hardware;
using HalPolicy = hal_1_3::HalPolicy;
+static const float TOLERANCE = 1.0f;
+
namespace
{
@@ -42,26 +40,6 @@ RequestArgument CreateRequestArgument(const std::vector<T>& value, unsigned int
return inputRequestArgument;
}
-// Returns true if the relative difference between two float values is less than the tolerance value given.
-// This is used because the floating point comparison tolerance (set on each BOOST_AUTO_TEST_CASE) does not work!
-bool TolerantCompareEqual(float a, float b, float tolerance = 1.0f)
-{
- float rd;
- if (a == 0.0f)
- {
- rd = fabs(b);
- }
- else if (b == 0.0f)
- {
- rd = fabs(a);
- }
- else
- {
- rd = boost::math::relative_difference(a, b);
- }
- return rd < tolerance;
-}
-
// Helper function to create an OperandLifeTime::NO_VALUE for testing.
// To be used on optional input operands that have no values - these are valid and should be tested.
HalPolicy::OperandLifeTime CreateNoValueLifeTime(const hidl_vec<uint32_t>& dimensions)
@@ -85,12 +63,6 @@ void ExecuteModel(const armnn_driver::hal_1_3::HalPolicy::Model& model,
}
}
-#ifndef ARMCOMPUTECL_ENABLED
-static const std::array<armnn::Compute, 1> COMPUTE_DEVICES = {{ armnn::Compute::CpuRef }};
-#else
-static const std::array<armnn::Compute, 2> COMPUTE_DEVICES = {{ armnn::Compute::CpuRef, armnn::Compute::CpuAcc }};
-#endif
-
// Add our own tests here since we skip the qlstm tests which Google supplies (because of non-const weights)
void QLstmTestImpl(const hidl_vec<uint32_t>& inputDimensions,
const std::vector<int8_t>& inputValue,
@@ -527,8 +499,8 @@ void QLstmTestImpl(const hidl_vec<uint32_t>& inputDimensions,
// check the results
for (size_t i = 0; i < outputStateOutValue.size(); ++i)
{
- BOOST_TEST(TolerantCompareEqual(outputStateOutValue[i], outputStateOutData[i]),
- "outputStateOut[" << i << "]: " << outputStateOutValue[i] << " != " << outputStateOutData[i]);
+ CHECK_MESSAGE(outputStateOutValue[i] == doctest::Approx( outputStateOutData[i] ).epsilon(TOLERANCE),
+ "outputStateOut[" << i << "]: " << outputStateOutValue[i] << " != " << outputStateOutData[i]);
}
// CELL STATE OUTPUT Does not match currently: IVGCVSW-4860 Verify remaining VTS tests (2) for QLSTM
@@ -541,8 +513,8 @@ void QLstmTestImpl(const hidl_vec<uint32_t>& inputDimensions,
for (size_t i = 0; i < outputValue.size(); ++i)
{
- BOOST_TEST(TolerantCompareEqual(outputValue[i], outputData[i]),
- "output[" << i << "]: " << outputValue[i] << " != " << outputData[i]);
+ CHECK_MESSAGE(outputValue[i] == doctest::Approx( outputData[i] ).epsilon(TOLERANCE),
+ "output[" << i << "]: " << outputValue[i] << " != " << outputData[i]);
}
}
@@ -1028,19 +1000,34 @@ void DynamicOutputQLstmWithNoProjection(armnn::Compute compute)
} // anonymous namespace
// Support is not added yet
-//BOOST_DATA_TEST_CASE(QLSTMWithProjectionTest, COMPUTE_DEVICES)
+//TEST_CASE(QLSTMWithProjectionTest, COMPUTE_DEVICES)
//{
// QLstmWithProjection(sample);
//}
-BOOST_DATA_TEST_CASE(QLSTMWithNoProjectionTest, COMPUTE_DEVICES)
+TEST_SUITE("QLSTMTests_CpuRef")
{
- QLstmWithNoProjection(sample);
-}
+ TEST_CASE("QLSTMWithNoProjectionTest_CpuRef")
+ {
+ QLstmWithNoProjection(armnn::Compute::CpuRef);
+ }
-BOOST_DATA_TEST_CASE(DynamicOutputQLSTMWithNoProjectionTest, COMPUTE_DEVICES)
-{
- DynamicOutputQLstmWithNoProjection(sample);
+ TEST_CASE("DynamicOutputQLstmWithNoProjection_CpuRef")
+ {
+ DynamicOutputQLstmWithNoProjection(armnn::Compute::CpuRef);
+ }
}
+#ifdef ARMCOMPUTECL_ENABLED
+TEST_SUITE("QLSTMTests_CpuAcc")
+{
+ TEST_CASE("QLSTMWithNoProjectionTest_CpuAcc")
+ {
+ QLstmWithNoProjection(armnn::Compute::CpuAcc);
+ }
-BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file
+ TEST_CASE("DynamicOutputQLstmWithNoProjection_CpuAcc")
+ {
+ DynamicOutputQLstmWithNoProjection(armnn::Compute::CpuAcc);
+ }
+}
+#endif
diff --git a/test/1.3/QosTests.cpp b/test/1.3/QosTests.cpp
index 9fd66880..3b064052 100644
--- a/test/1.3/QosTests.cpp
+++ b/test/1.3/QosTests.cpp
@@ -10,12 +10,10 @@
#include <armnn/utility/IgnoreUnused.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/test/data/test_case.hpp>
-
-
-BOOST_AUTO_TEST_SUITE(QosTests)
+#include <doctest/doctest.h>
+TEST_SUITE("QosTests")
+{
using ArmnnDriver = armnn_driver::ArmnnDriver;
using DriverOptions = armnn_driver::DriverOptions;
@@ -40,13 +38,7 @@ void ExecuteModel(const armnn_driver::hal_1_3::HalPolicy::Model& model,
}
}
-#ifndef ARMCOMPUTECL_ENABLED
-static const std::array<armnn::Compute, 1> COMPUTE_DEVICES = {{ armnn::Compute::CpuRef }};
-#else
-static const std::array<armnn::Compute, 2> COMPUTE_DEVICES = {{ armnn::Compute::CpuRef, armnn::Compute::CpuAcc }};
-#endif
-
-BOOST_AUTO_TEST_CASE(ConcurrentExecuteWithQosPriority)
+TEST_CASE("ConcurrentExecuteWithQosPriority")
{
ALOGI("ConcurrentExecuteWithQOSPriority: entry");
@@ -102,7 +94,7 @@ BOOST_AUTO_TEST_CASE(ConcurrentExecuteWithQosPriority)
preparedModelsSize++;
}
- BOOST_TEST(maxRequests == preparedModelsSize);
+ CHECK(maxRequests == preparedModelsSize);
// construct the request data
V1_0::DataLocation inloc = {};
@@ -172,15 +164,15 @@ BOOST_AUTO_TEST_CASE(ConcurrentExecuteWithQosPriority)
{
if (i < 15)
{
- BOOST_TEST(outdata[i][0] == 152);
+ CHECK(outdata[i][0] == 152);
}
else if (i < 30)
{
- BOOST_TEST(outdata[i][0] == 141);
+ CHECK(outdata[i][0] == 141);
}
else
{
- BOOST_TEST(outdata[i][0] == 159);
+ CHECK(outdata[i][0] == 159);
}
}
@@ -189,4 +181,4 @@ BOOST_AUTO_TEST_CASE(ConcurrentExecuteWithQosPriority)
} // anonymous namespace
-BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file
+} \ No newline at end of file