diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-05-17 12:15:30 +0100 |
---|---|---|
committer | Derek Lamberti <derek.lamberti@arm.com> | 2019-05-20 15:34:20 +0000 |
commit | f02e6cd728a0bceea221120ec039a4b66436d51d (patch) | |
tree | 962189ebf8b48c0bb74518aba0f5dbaefa58861a /src/backends/backendsCommon/test/CommonTestUtils.cpp | |
parent | 4ed6c83a82948314abffdaa17e96c39ac82f89e4 (diff) | |
download | armnn-f02e6cd728a0bceea221120ec039a4b66436d51d.tar.gz |
IVGCVSW-3030 Add unit testing for the Optimization API
* Added OptimizeSubgraphViewTests file covering a number of
use cases for the Optimization API
* Fixed a bug in the sub-graph selector algorithm that skipped the
first layer in a sub-graph if it wasn't an input layer
* Changed the graph splitting logic to make use of maps instead of
unordered_maps to keep the split sub-graphs in consistent order
between executions
* Added more common unit test utils
* Minor fixes to comply to the include file conventions
Change-Id: Iad464eaedd004109e5ef41aa487cea3ad86177d3
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Diffstat (limited to 'src/backends/backendsCommon/test/CommonTestUtils.cpp')
-rw-r--r-- | src/backends/backendsCommon/test/CommonTestUtils.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/backends/backendsCommon/test/CommonTestUtils.cpp b/src/backends/backendsCommon/test/CommonTestUtils.cpp new file mode 100644 index 0000000000..7685626935 --- /dev/null +++ b/src/backends/backendsCommon/test/CommonTestUtils.cpp @@ -0,0 +1,59 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "CommonTestUtils.hpp" + +#include <backendsCommon/IBackendInternal.hpp> + +using namespace armnn; + +void Connect(armnn::IConnectableLayer* from, armnn::IConnectableLayer* to, const armnn::TensorInfo& tensorInfo, + unsigned int fromIndex, unsigned int toIndex) +{ + from->GetOutputSlot(fromIndex).Connect(to->GetInputSlot(toIndex)); + from->GetOutputSlot(fromIndex).SetTensorInfo(tensorInfo); +} + +SubgraphView::InputSlots CreateInputsFrom(const std::vector<Layer*>& layers) +{ + SubgraphView::InputSlots result; + for (auto&& layer : layers) + { + for (auto&& it = layer->BeginInputSlots(); it != layer->EndInputSlots(); ++it) + { + result.push_back(&(*it)); + } + } + return result; +} + +SubgraphView::OutputSlots CreateOutputsFrom(const std::vector<Layer*>& layers) +{ + SubgraphView::OutputSlots result; + for (auto && layer : layers) + { + for (auto&& it = layer->BeginOutputSlots(); it != layer->EndOutputSlots(); ++it) + { + result.push_back(&(*it)); + } + } + return result; +} + +SubgraphView::SubgraphViewPtr CreateSubgraphViewFrom(SubgraphView::InputSlots&& inputs, + SubgraphView::OutputSlots&& outputs, + SubgraphView::Layers&& layers) +{ + return std::make_unique<SubgraphView>(std::move(inputs), std::move(outputs), std::move(layers)); +} + +armnn::IBackendInternalUniquePtr CreateBackendObject(const armnn::BackendId& backendId) +{ + auto& backendRegistry = BackendRegistryInstance(); + auto backendFactory = backendRegistry.GetFactory(backendId); + auto backendObjPtr = backendFactory(); + + return backendObjPtr; +} |