From a983e4699082a0b1ef685bab7354f2ad9cd37a44 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Wed, 20 May 2020 16:12:19 +0100 Subject: Updating Doxygen documentation for 20.05 release. Change-Id: I4d624343ed5fd6ae269c3d53532903084508fd14 Signed-off-by: Colm Donelan --- 20.05/_unit_tests_8hpp_source.xhtml | 136 ++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 20.05/_unit_tests_8hpp_source.xhtml (limited to '20.05/_unit_tests_8hpp_source.xhtml') diff --git a/20.05/_unit_tests_8hpp_source.xhtml b/20.05/_unit_tests_8hpp_source.xhtml new file mode 100644 index 0000000000..2d0ad14376 --- /dev/null +++ b/20.05/_unit_tests_8hpp_source.xhtml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + +ArmNN: src/armnn/test/UnitTests.hpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.05 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
UnitTests.hpp
+
+
+Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 #include <armnn/Logging.hpp>
8 #include <armnn/Utils.hpp>
12 #include "TensorHelpers.hpp"
13 #include <boost/test/unit_test.hpp>
14 
15 inline void ConfigureLoggingTest()
16 {
17  // Configures logging for both the ARMNN library and this test program.
19 }
20 
21 // The following macros require the caller to have defined FactoryType, with one of the following using statements:
22 //
23 // using FactoryType = armnn::RefWorkloadFactory;
24 // using FactoryType = armnn::ClWorkloadFactory;
25 // using FactoryType = armnn::NeonWorkloadFactory;
26 
27 /// Executes BOOST_TEST on CompareTensors() return value so that the predicate_result message is reported.
28 /// If the test reports itself as not supported then the tensors are not compared.
29 /// Additionally this checks that the supportedness reported by the test matches the name of the test.
30 /// Unsupported tests must be 'tagged' by including "UNSUPPORTED" in their name.
31 /// This is useful because it clarifies that the feature being tested is not actually supported
32 /// (a passed test with the name of a feature would imply that feature was supported).
33 /// If support is added for a feature, the test case will fail because the name incorrectly contains UNSUPPORTED.
34 /// If support is removed for a feature, the test case will fail because the name doesn't contain UNSUPPORTED.
35 template <typename T, std::size_t n>
36 void CompareTestResultIfSupported(const std::string& testName, const LayerTestResult<T, n>& testResult)
37 {
38  bool testNameIndicatesUnsupported = testName.find("UNSUPPORTED") != std::string::npos;
39  BOOST_CHECK_MESSAGE(testNameIndicatesUnsupported != testResult.supported,
40  "The test name does not match the supportedness it is reporting");
41  if (testResult.supported)
42  {
43  BOOST_TEST(CompareTensors(testResult.output, testResult.outputExpected, testResult.compareBoolean));
44  }
45 }
46 
47 template <typename T, std::size_t n>
48 void CompareTestResultIfSupported(const std::string& testName, const std::vector<LayerTestResult<T, n>>& testResult)
49 {
50  bool testNameIndicatesUnsupported = testName.find("UNSUPPORTED") != std::string::npos;
51  for (unsigned int i = 0; i < testResult.size(); ++i)
52  {
53  BOOST_CHECK_MESSAGE(testNameIndicatesUnsupported != testResult[i].supported,
54  "The test name does not match the supportedness it is reporting");
55  if (testResult[i].supported)
56  {
57  BOOST_TEST(CompareTensors(testResult[i].output, testResult[i].outputExpected));
58  }
59  }
60 }
61 
62 template<typename FactoryType, typename TFuncPtr, typename... Args>
63 void RunTestFunction(const char* testName, TFuncPtr testFunction, Args... args)
64 {
65  std::unique_ptr<armnn::Profiler> profiler = std::make_unique<armnn::Profiler>();
67 
68  auto memoryManager = WorkloadFactoryHelper<FactoryType>::GetMemoryManager();
69  FactoryType workloadFactory = WorkloadFactoryHelper<FactoryType>::GetFactory(memoryManager);
70 
71  auto testResult = (*testFunction)(workloadFactory, memoryManager, args...);
72  CompareTestResultIfSupported(testName, testResult);
73 
75 }
76 
77 #define ARMNN_SIMPLE_TEST_CASE(TestName, TestFunction) \
78  BOOST_AUTO_TEST_CASE(TestName) \
79  { \
80  TestFunction(); \
81  }
82 
83 #define ARMNN_AUTO_TEST_CASE(TestName, TestFunction, ...) \
84  BOOST_AUTO_TEST_CASE(TestName) \
85  { \
86  RunTestFunction<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
87  }
88 
89 template<typename FactoryType, typename TFuncPtr, typename... Args>
90 void CompareRefTestFunction(const char* testName, TFuncPtr testFunction, Args... args)
91 {
92  auto memoryManager = WorkloadFactoryHelper<FactoryType>::GetMemoryManager();
93  FactoryType workloadFactory = WorkloadFactoryHelper<FactoryType>::GetFactory(memoryManager);
94 
95  armnn::RefWorkloadFactory refWorkloadFactory;
96 
97  auto testResult = (*testFunction)(workloadFactory, memoryManager, refWorkloadFactory, args...);
98  CompareTestResultIfSupported(testName, testResult);
99 }
100 
101 #define ARMNN_COMPARE_REF_AUTO_TEST_CASE(TestName, TestFunction, ...) \
102  BOOST_AUTO_TEST_CASE(TestName) \
103  { \
104  CompareRefTestFunction<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
105  }
106 
107 #define ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(TestName, Fixture, TestFunction, ...) \
108  BOOST_FIXTURE_TEST_CASE(TestName, Fixture) \
109  { \
110  CompareRefTestFunction<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
111  }
+ + +
void RegisterProfiler(Profiler *profiler)
Definition: Profiling.cpp:493
+
static ProfilerManager & GetInstance()
Definition: Profiling.cpp:486
+
void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
Configures the logging behaviour of the ARMNN library.
Definition: Utils.cpp:10
+ +
ISubgraphViewConverter supported
+
boost::test_tools::predicate_result CompareTensors(const boost::multi_array< T, n > &a, const boost::multi_array< T, n > &b, bool compareBoolean=false)
+
boost::multi_array< T, n > outputExpected
+
void CompareRefTestFunction(const char *testName, TFuncPtr testFunction, Args... args)
Definition: UnitTests.hpp:90
+ + +
void RunTestFunction(const char *testName, TFuncPtr testFunction, Args... args)
Definition: UnitTests.hpp:63
+
void CompareTestResultIfSupported(const std::string &testName, const LayerTestResult< T, n > &testResult)
Executes BOOST_TEST on CompareTensors() return value so that the predicate_result message is reported...
Definition: UnitTests.hpp:36
+ +
void ConfigureLoggingTest()
Definition: UnitTests.hpp:15
+ + +
boost::multi_array< T, n > output
+ +
ClWorkloadFactory FactoryType
+ +
+
+ + + + -- cgit v1.2.1