diff options
author | narpra01 <narumol.prangnawarat@arm.com> | 2018-12-21 18:30:00 +0000 |
---|---|---|
committer | Les Bell <les.bell@arm.com> | 2019-01-02 09:25:42 +0000 |
commit | 6f37f83a27160948fee366b9f195c52f78cb88f0 (patch) | |
tree | d09a8d5769c3ac2c8f45660d305e9a6124716310 /src/armnn/test | |
parent | c48ac8c8cea1748ebfef15144f070799d4a129c3 (diff) | |
download | armnn-6f37f83a27160948fee366b9f195c52f78cb88f0.tar.gz |
IVGCVSW-2353 Ignore control inputs in TensorFlow parser
* Allow control inputs from TensorFlow graph but ignore them in ArmNN graph.
* Add utility function to test ArmNN graph structure.
* Add ArmNN graph structure tests in TensorFlow paresr to ensure that control inputs
are ignored in ArmNN graph as well as their inputs that are not used anywhere else.
Change-Id: Ib0ea0d2df85e3fc79b748fa4c9d20e0649352bc1
Diffstat (limited to 'src/armnn/test')
-rw-r--r-- | src/armnn/test/GraphTests.cpp | 12 | ||||
-rw-r--r-- | src/armnn/test/GraphUtils.cpp | 63 | ||||
-rw-r--r-- | src/armnn/test/GraphUtils.hpp | 28 |
3 files changed, 76 insertions, 27 deletions
diff --git a/src/armnn/test/GraphTests.cpp b/src/armnn/test/GraphTests.cpp index 0c0ba8b000..cca4653509 100644 --- a/src/armnn/test/GraphTests.cpp +++ b/src/armnn/test/GraphTests.cpp @@ -29,18 +29,6 @@ bool CheckOrder(const armnn::Graph& graph, const armnn::Layer* first, const armn return (secondPos != order.end()); } -static armnn::Layer* GetFirstLayerWithName(armnn::Graph& graph, const std::string& name) -{ - for (auto&& layer : graph) - { - if (layer->GetNameStr() == name) - { - return layer; - } - } - return nullptr; -} - BOOST_AUTO_TEST_SUITE(Graph) BOOST_AUTO_TEST_CASE(ClassGraph) diff --git a/src/armnn/test/GraphUtils.cpp b/src/armnn/test/GraphUtils.cpp new file mode 100644 index 0000000000..1f9bb44d3d --- /dev/null +++ b/src/armnn/test/GraphUtils.cpp @@ -0,0 +1,63 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "GraphUtils.hpp" + +bool GraphHasNamedLayer(const armnn::Graph& graph, const std::string& name) +{ + for (auto&& layer : graph) + { + if (layer->GetName() == name) + { + return true; + } + } + return false; +} + +armnn::Layer* GetFirstLayerWithName(armnn::Graph& graph, const std::string& name) +{ + for (auto&& layer : graph) + { + if (layer->GetNameStr() == name) + { + return layer; + } + } + return nullptr; +} + +bool CheckNumberOfInputSlot(armnn::Layer* layer, unsigned int num) +{ + return layer->GetNumInputSlots() == num; +} + +bool CheckNumberOfOutputSlot(armnn::Layer* layer, unsigned int num) +{ + return layer->GetNumOutputSlots() == num; +} + +bool IsConnected(armnn::Layer* srcLayer, armnn::Layer* destLayer, + unsigned int srcSlot, unsigned int destSlot, + const armnn::TensorInfo& expectedTensorInfo) +{ + const armnn::IOutputSlot& outputSlot = srcLayer->GetOutputSlot(srcSlot); + const armnn::TensorInfo& tensorInfo = outputSlot.GetTensorInfo(); + if (expectedTensorInfo != tensorInfo) + { + return false; + } + const unsigned int numConnections = outputSlot.GetNumConnections(); + for (unsigned int c = 0; c < numConnections; ++c) + { + auto inputSlot = boost::polymorphic_downcast<const armnn::InputSlot*>(outputSlot.GetConnection(c)); + if (inputSlot->GetOwningLayer().GetNameStr() == destLayer->GetNameStr() && + inputSlot->GetSlotIndex() == destSlot) + { + return true; + } + } + return false; +} diff --git a/src/armnn/test/GraphUtils.hpp b/src/armnn/test/GraphUtils.hpp index 04f9727dc0..b51e4d179e 100644 --- a/src/armnn/test/GraphUtils.hpp +++ b/src/armnn/test/GraphUtils.hpp @@ -8,18 +8,16 @@ #include <string> -namespace -{ - -bool GraphHasNamedLayer(const armnn::Graph& graph, const std::string& name) -{ - for (auto&& layer : graph) - { - if (layer->GetName() == name) - { - return true; - } - } - return false; -} -}
\ No newline at end of file + +bool GraphHasNamedLayer(const armnn::Graph& graph, const std::string& name); + +armnn::Layer* GetFirstLayerWithName(armnn::Graph& graph, const std::string& name); + +bool CheckNumberOfInputSlot(armnn::Layer* layer, unsigned int num); + +bool CheckNumberOfOutputSlot(armnn::Layer* layer, unsigned int num); + +bool IsConnected(armnn::Layer* srcLayer, armnn::Layer* destLayer, + unsigned int srcSlot, unsigned int destSlot, + const armnn::TensorInfo& expectedTensorInfo); + |