From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- 20.02/_unit_tests_8hpp_source.xhtml | 136 ++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 20.02/_unit_tests_8hpp_source.xhtml (limited to '20.02/_unit_tests_8hpp_source.xhtml') diff --git a/20.02/_unit_tests_8hpp_source.xhtml b/20.02/_unit_tests_8hpp_source.xhtml new file mode 100644 index 0000000000..64aecc728a --- /dev/null +++ b/20.02/_unit_tests_8hpp_source.xhtml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + +ArmNN: src/armnn/test/UnitTests.hpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
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 }
74 
75 #define ARMNN_SIMPLE_TEST_CASE(TestName, TestFunction) \
76  BOOST_AUTO_TEST_CASE(TestName) \
77  { \
78  TestFunction(); \
79  }
80 
81 #define ARMNN_AUTO_TEST_CASE(TestName, TestFunction, ...) \
82  BOOST_AUTO_TEST_CASE(TestName) \
83  { \
84  RunTestFunction<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
85  }
86 
87 template<typename FactoryType, typename TFuncPtr, typename... Args>
88 void CompareRefTestFunction(const char* testName, TFuncPtr testFunction, Args... args)
89 {
90  auto memoryManager = WorkloadFactoryHelper<FactoryType>::GetMemoryManager();
91  FactoryType workloadFactory = WorkloadFactoryHelper<FactoryType>::GetFactory(memoryManager);
92 
93  armnn::RefWorkloadFactory refWorkloadFactory;
94 
95  auto testResult = (*testFunction)(workloadFactory, memoryManager, refWorkloadFactory, args...);
96  CompareTestResultIfSupported(testName, testResult);
97 }
98 
99 #define ARMNN_COMPARE_REF_AUTO_TEST_CASE(TestName, TestFunction, ...) \
100  BOOST_AUTO_TEST_CASE(TestName) \
101  { \
102  CompareRefTestFunction<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
103  }
104 
105 #define ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(TestName, Fixture, TestFunction, ...) \
106  BOOST_FIXTURE_TEST_CASE(TestName, Fixture) \
107  { \
108  CompareRefTestFunction<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
109  }
+ + +
void RegisterProfiler(Profiler *profiler)
Definition: Profiling.cpp:494
+
static ProfilerManager & GetInstance()
Definition: Profiling.cpp:487
+
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:88
+ + +
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