aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/test/TestUtils.hpp
diff options
context:
space:
mode:
authorRob Hughes <robert.hughes@arm.com>2019-09-24 09:34:53 +0100
committerJim Flynn Arm <jim.flynn@arm.com>2019-09-25 02:44:48 +0000
commit95e73d77b9a79f7d350a39d85f07d09cd58422cc (patch)
tree8b713e8d29d433a28b29b8a9ce34052e8cccd08c /src/armnn/test/TestUtils.hpp
parent4833cea9036df428634cf64d8f1c4b54fc5da41f (diff)
downloadarmnn-95e73d77b9a79f7d350a39d85f07d09cd58422cc.tar.gz
NNXSW-1826 Move tests for Optimization classes to separate files
This splits up the >1000 line OptimizerTests.cpp file. Each Optimization class now has its own test file, all of which are in a subfolder of tests called "optimizations". The original OptimizerTests.cpp now contains mostly (completely?) tests for validating output shapes, which perhaps should be moved to test files specific to the layer types they are testing. Change-Id: Icd1196cad8b720abcb156921aab1adbd4026756b Signed-off-by: Rob Hughes <robert.hughes@arm.com>
Diffstat (limited to 'src/armnn/test/TestUtils.hpp')
-rw-r--r--src/armnn/test/TestUtils.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/armnn/test/TestUtils.hpp b/src/armnn/test/TestUtils.hpp
index 9129d91886..9b1a3bf18d 100644
--- a/src/armnn/test/TestUtils.hpp
+++ b/src/armnn/test/TestUtils.hpp
@@ -6,6 +6,44 @@
#pragma once
#include <armnn/INetwork.hpp>
+#include <Graph.hpp>
void Connect(armnn::IConnectableLayer* from, armnn::IConnectableLayer* to, const armnn::TensorInfo& tensorInfo,
unsigned int fromIndex = 0, unsigned int toIndex = 0);
+
+template <typename LayerT>
+bool IsLayerOfType(const armnn::Layer* const layer)
+{
+ return (layer->GetType() == armnn::LayerEnumOf<LayerT>());
+}
+
+inline bool CheckSequence(const armnn::Graph::ConstIterator first, const armnn::Graph::ConstIterator last)
+{
+ return (first == last);
+}
+
+/// Checks each unary function in Us evaluates true for each correspondent layer in the sequence [first, last).
+template <typename U, typename... Us>
+bool CheckSequence(const armnn::Graph::ConstIterator first, const armnn::Graph::ConstIterator last, U&& u, Us&&... us)
+{
+ return u(*first) && CheckSequence(std::next(first), last, us...);
+}
+
+template <typename LayerT>
+bool CheckRelatedLayers(armnn::Graph& graph, const std::list<std::string>& testRelatedLayers)
+{
+ for (auto& layer : graph)
+ {
+ if (layer->GetType() == armnn::LayerEnumOf<LayerT>())
+ {
+ auto& relatedLayers = layer->GetRelatedLayerNames();
+ if (!std::equal(relatedLayers.begin(), relatedLayers.end(), testRelatedLayers.begin(),
+ testRelatedLayers.end()))
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}