From fd627ffaec8fd8801d980b4c91ee7c0607ab6aaf Mon Sep 17 00:00:00 2001 From: Jan Eilers Date: Thu, 25 Feb 2021 17:44:00 +0000 Subject: IVGCVSW-5687 Update Doxygen Docu * Update Doxygen Documentation for 21.02 release Signed-off-by: Jan Eilers Change-Id: I9ed2f9caab038836ea99d7b378d7899fe431a4e5 --- 21.02/_unit_tests_8hpp.xhtml | 708 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 708 insertions(+) create mode 100644 21.02/_unit_tests_8hpp.xhtml (limited to '21.02/_unit_tests_8hpp.xhtml') diff --git a/21.02/_unit_tests_8hpp.xhtml b/21.02/_unit_tests_8hpp.xhtml new file mode 100644 index 0000000000..ed8205bde7 --- /dev/null +++ b/21.02/_unit_tests_8hpp.xhtml @@ -0,0 +1,708 @@ + + + + + + + + + + + + + +ArmNN: src/armnn/test/UnitTests.hpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  21.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
UnitTests.hpp File Reference
+
+
+ +

Go to the source code of this file.

+ + + + + + + + + + + + + + + + +

+Macros

#define ARMNN_SIMPLE_TEST_CASE(TestName, TestFunction)
 
#define ARMNN_AUTO_TEST_CASE(TestName, TestFunction, ...)
 
#define ARMNN_AUTO_TEST_CASE_WITH_THF(TestName, TestFunction, ...)
 
#define ARMNN_COMPARE_REF_AUTO_TEST_CASE(TestName, TestFunction, ...)
 
#define ARMNN_COMPARE_REF_AUTO_TEST_CASE_WITH_THF(TestName, TestFunction, ...)
 
#define ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(TestName, Fixture, TestFunction, ...)
 
#define ARMNN_COMPARE_REF_FIXTURE_TEST_CASE_WITH_THF(TestName, Fixture, TestFunction, ...)
 
+ + + + + + + + + + + + + + + + + + + + + + +

+Functions

void ConfigureLoggingTest ()
 
template<typename T , std::size_t n>
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. More...
 
template<typename T , std::size_t n>
void CompareTestResultIfSupported (const std::string &testName, const std::vector< LayerTestResult< T, n >> &testResult)
 
template<typename FactoryType , typename TFuncPtr , typename... Args>
void RunTestFunction (const char *testName, TFuncPtr testFunction, Args... args)
 
template<typename FactoryType , typename TFuncPtr , typename... Args>
void RunTestFunctionUsingTensorHandleFactory (const char *testName, TFuncPtr testFunction, Args... args)
 
template<typename FactoryType , typename TFuncPtr , typename... Args>
void CompareRefTestFunction (const char *testName, TFuncPtr testFunction, Args... args)
 
template<typename FactoryType , typename TFuncPtr , typename... Args>
void CompareRefTestFunctionUsingTensorHandleFactory (const char *testName, TFuncPtr testFunction, Args... args)
 
+

Macro Definition Documentation

+ +

◆ ARMNN_AUTO_TEST_CASE

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
#define ARMNN_AUTO_TEST_CASE( TestName,
 TestFunction,
 ... 
)
+
+Value:
{ \
RunTestFunction<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
}
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
+
+

Definition at line 103 of file UnitTests.hpp.

+ +
+
+ +

◆ ARMNN_AUTO_TEST_CASE_WITH_THF

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
#define ARMNN_AUTO_TEST_CASE_WITH_THF( TestName,
 TestFunction,
 ... 
)
+
+Value:
{ \
RunTestFunctionUsingTensorHandleFactory<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
}
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
+
+

Definition at line 109 of file UnitTests.hpp.

+ +
+
+ +

◆ ARMNN_COMPARE_REF_AUTO_TEST_CASE

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
#define ARMNN_COMPARE_REF_AUTO_TEST_CASE( TestName,
 TestFunction,
 ... 
)
+
+Value:
{ \
CompareRefTestFunction<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
}
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
+
+

Definition at line 143 of file UnitTests.hpp.

+ +
+
+ +

◆ ARMNN_COMPARE_REF_AUTO_TEST_CASE_WITH_THF

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
#define ARMNN_COMPARE_REF_AUTO_TEST_CASE_WITH_THF( TestName,
 TestFunction,
 ... 
)
+
+Value:
{ \
CompareRefTestFunctionUsingTensorHandleFactory<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
}
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
+
+

Definition at line 149 of file UnitTests.hpp.

+ +
+
+ +

◆ ARMNN_COMPARE_REF_FIXTURE_TEST_CASE

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define ARMNN_COMPARE_REF_FIXTURE_TEST_CASE( TestName,
 Fixture,
 TestFunction,
 ... 
)
+
+Value:
BOOST_FIXTURE_TEST_CASE(TestName, Fixture) \
{ \
CompareRefTestFunction<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
}
BOOST_FIXTURE_TEST_CASE(AddCopyLayers, CopyLayersFixture)
Definition: GraphTests.cpp:516
+
+

Definition at line 155 of file UnitTests.hpp.

+ +
+
+ +

◆ ARMNN_COMPARE_REF_FIXTURE_TEST_CASE_WITH_THF

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define ARMNN_COMPARE_REF_FIXTURE_TEST_CASE_WITH_THF( TestName,
 Fixture,
 TestFunction,
 ... 
)
+
+Value:
BOOST_FIXTURE_TEST_CASE(TestName, Fixture) \
{ \
CompareRefTestFunctionUsingTensorHandleFactory<FactoryType>(#TestName, &TestFunction, ##__VA_ARGS__); \
}
BOOST_FIXTURE_TEST_CASE(AddCopyLayers, CopyLayersFixture)
Definition: GraphTests.cpp:516
+
+

Definition at line 161 of file UnitTests.hpp.

+ +
+
+ +

◆ ARMNN_SIMPLE_TEST_CASE

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define ARMNN_SIMPLE_TEST_CASE( TestName,
 TestFunction 
)
+
+Value:
{ \
TestFunction(); \
}
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
+
+

Definition at line 97 of file UnitTests.hpp.

+ +
+
+

Function Documentation

+ +

◆ CompareRefTestFunction()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CompareRefTestFunction (const char * testName,
TFuncPtr testFunction,
Args... args 
)
+
+ +

Definition at line 116 of file UnitTests.hpp.

+ +

References CompareTestResultIfSupported().

+
117 {
118  auto memoryManager = WorkloadFactoryHelper<FactoryType>::GetMemoryManager();
119  FactoryType workloadFactory = WorkloadFactoryHelper<FactoryType>::GetFactory(memoryManager);
120 
121  armnn::RefWorkloadFactory refWorkloadFactory;
122 
123  auto testResult = (*testFunction)(workloadFactory, memoryManager, refWorkloadFactory, args...);
124  CompareTestResultIfSupported(testName, testResult);
125 }
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:38
+ +
ClWorkloadFactory FactoryType
+
+
+
+ +

◆ CompareRefTestFunctionUsingTensorHandleFactory()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CompareRefTestFunctionUsingTensorHandleFactory (const char * testName,
TFuncPtr testFunction,
Args... args 
)
+
+ +

Definition at line 128 of file UnitTests.hpp.

+ +

References CompareTestResultIfSupported().

+
129 {
130  auto memoryManager = WorkloadFactoryHelper<FactoryType>::GetMemoryManager();
131  FactoryType workloadFactory = WorkloadFactoryHelper<FactoryType>::GetFactory(memoryManager);
132 
133  armnn::RefWorkloadFactory refWorkloadFactory;
134  auto tensorHandleFactory = WorkloadFactoryHelper<FactoryType>::GetTensorHandleFactory(memoryManager);
135  auto refTensorHandleFactory =
136  RefWorkloadFactoryHelper::GetTensorHandleFactory(memoryManager);
137 
138  auto testResult = (*testFunction)(
139  workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, args...);
140  CompareTestResultIfSupported(testName, testResult);
141 }
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:38
+ +
ClWorkloadFactory FactoryType
+
+
+
+ +

◆ CompareTestResultIfSupported() [1/2]

+ +
+
+ + + + + + + + + + + + + + + + + + +
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.

+

If the test reports itself as not supported then the tensors are not compared. Additionally this checks that the supportedness reported by the test matches the name of the test. Unsupported tests must be 'tagged' by including "UNSUPPORTED" in their name. This is useful because it clarifies that the feature being tested is not actually supported (a passed test with the name of a feature would imply that feature was supported). If support is added for a feature, the test case will fail because the name incorrectly contains UNSUPPORTED. If support is removed for a feature, the test case will fail because the name doesn't contain UNSUPPORTED.

+ +

Definition at line 38 of file UnitTests.hpp.

+ +

References LayerTestResult< T, n >::compareBoolean, CompareTensors(), LayerTestResult< T, n >::output, LayerTestResult< T, n >::outputExpected, and LayerTestResult< T, n >::supported.

+ +

Referenced by CompareRefTestFunction(), CompareRefTestFunctionUsingTensorHandleFactory(), RunTestFunction(), and RunTestFunctionUsingTensorHandleFactory().

+
39 {
40  bool testNameIndicatesUnsupported = testName.find("UNSUPPORTED") != std::string::npos;
41  BOOST_CHECK_MESSAGE(testNameIndicatesUnsupported != testResult.supported,
42  "The test name does not match the supportedness it is reporting");
43  if (testResult.supported)
44  {
45  BOOST_TEST(CompareTensors(testResult.output, testResult.outputExpected, testResult.compareBoolean));
46  }
47 }
+
boost::test_tools::predicate_result CompareTensors(const boost::multi_array< T, n > &a, const boost::multi_array< T, n > &b, bool compareBoolean=false, bool isDynamic=false)
+
boost::multi_array< T, n > outputExpected
+
boost::multi_array< T, n > output
+ +
+
+
+ +

◆ CompareTestResultIfSupported() [2/2]

+ +
+
+ + + + + + + + + + + + + + + + + + +
void CompareTestResultIfSupported (const std::string & testName,
const std::vector< LayerTestResult< T, n >> & testResult 
)
+
+ +

Definition at line 50 of file UnitTests.hpp.

+ +

References CompareTensors().

+
51 {
52  bool testNameIndicatesUnsupported = testName.find("UNSUPPORTED") != std::string::npos;
53  for (unsigned int i = 0; i < testResult.size(); ++i)
54  {
55  BOOST_CHECK_MESSAGE(testNameIndicatesUnsupported != testResult[i].supported,
56  "The test name does not match the supportedness it is reporting");
57  if (testResult[i].supported)
58  {
59  BOOST_TEST(CompareTensors(testResult[i].output, testResult[i].outputExpected));
60  }
61  }
62 }
boost::test_tools::predicate_result CompareTensors(const boost::multi_array< T, n > &a, const boost::multi_array< T, n > &b, bool compareBoolean=false, bool isDynamic=false)
+
ISubgraphViewConverter supported
+
+
+
+ +

◆ ConfigureLoggingTest()

+ +
+
+ + + + + +
+ + + + + + + +
void ConfigureLoggingTest ()
+
+inline
+
+ +

Definition at line 17 of file UnitTests.hpp.

+ +

References armnn::ConfigureLogging(), and armnn::Fatal.

+
18 {
19  // Configures logging for both the ARMNN library and this test program.
21 }
void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
Configures the logging behaviour of the ARMNN library.
Definition: Utils.cpp:18
+ +
+
+
+ +

◆ RunTestFunction()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void RunTestFunction (const char * testName,
TFuncPtr testFunction,
Args... args 
)
+
+ +

Definition at line 65 of file UnitTests.hpp.

+ +

References CompareTestResultIfSupported(), ProfilerManager::GetInstance(), and ProfilerManager::RegisterProfiler().

+
66 {
67  std::unique_ptr<armnn::IProfiler> profiler = std::make_unique<armnn::IProfiler>();
69 
70  auto memoryManager = WorkloadFactoryHelper<FactoryType>::GetMemoryManager();
71  FactoryType workloadFactory = WorkloadFactoryHelper<FactoryType>::GetFactory(memoryManager);
72 
73  auto testResult = (*testFunction)(workloadFactory, memoryManager, args...);
74  CompareTestResultIfSupported(testName, testResult);
75 
77 }
static ProfilerManager & GetInstance()
Definition: Profiling.cpp:489
+
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:38
+
void RegisterProfiler(IProfiler *profiler)
Definition: Profiling.cpp:496
+
ClWorkloadFactory FactoryType
+
+
+
+ +

◆ RunTestFunctionUsingTensorHandleFactory()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void RunTestFunctionUsingTensorHandleFactory (const char * testName,
TFuncPtr testFunction,
Args... args 
)
+
+ +

Definition at line 81 of file UnitTests.hpp.

+ +

References CompareTestResultIfSupported(), ProfilerManager::GetInstance(), and ProfilerManager::RegisterProfiler().

+
82 {
83  std::unique_ptr<armnn::IProfiler> profiler = std::make_unique<armnn::IProfiler>();
85 
86  auto memoryManager = WorkloadFactoryHelper<FactoryType>::GetMemoryManager();
87  FactoryType workloadFactory = WorkloadFactoryHelper<FactoryType>::GetFactory(memoryManager);
88 
89  auto tensorHandleFactory = WorkloadFactoryHelper<FactoryType>::GetTensorHandleFactory(memoryManager);
90 
91  auto testResult = (*testFunction)(workloadFactory, memoryManager, tensorHandleFactory, args...);
92  CompareTestResultIfSupported(testName, testResult);
93 
95 }
static ProfilerManager & GetInstance()
Definition: Profiling.cpp:489
+
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:38
+
void RegisterProfiler(IProfiler *profiler)
Definition: Profiling.cpp:496
+
ClWorkloadFactory FactoryType
+
+
+
+
+
+ + + + -- cgit v1.2.1