From e2c82fee3b6d38f6e79412c78176792b817defd0 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 2 Oct 2017 18:51:47 +0100 Subject: COMPMID-550: Adds support for branches. Change-Id: I778007c9221ce3156400284c4039b90245eb2b7f Reviewed-on: http://mpd-gerrit.cambridge.arm.com/90043 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- src/graph/Graph.cpp | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'src/graph/Graph.cpp') diff --git a/src/graph/Graph.cpp b/src/graph/Graph.cpp index 7dddb1cd9a..b86330b658 100644 --- a/src/graph/Graph.cpp +++ b/src/graph/Graph.cpp @@ -26,16 +26,18 @@ #include "arm_compute/graph/CL/CLMap.h" #include "arm_compute/graph/CL/CLUnmap.h" #include "arm_compute/graph/INode.h" +#include "arm_compute/graph/ITensorObject.h" #include "arm_compute/graph/Tensor.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/Tensor.h" +#include "support/ToolchainSupport.h" using namespace arm_compute::graph; struct Stage { - Tensor *_input; - Tensor *_output; + ITensorObject *_input; + ITensorObject *_output; std::unique_ptr _function; }; @@ -48,20 +50,21 @@ public: */ void configure(GraphHints _next_hints); - GraphContext _ctx{}; - std::vector _pipeline{}; - std::vector> _tensors{}; - std::vector> _nodes{}; - GraphHints _current_hints{}; - GraphHints _next_hints{}; - std::unique_ptr _graph_input{ nullptr }; - std::unique_ptr _graph_output{ nullptr }; - std::unique_ptr _current_node{ nullptr }; - Tensor *_current_output{ nullptr }; + GraphContext _ctx{}; + std::vector _pipeline{}; + std::vector> _tensors{}; + std::vector> _nodes{}; + GraphHints _current_hints{}; + GraphHints _next_hints{}; + std::unique_ptr _graph_input{ nullptr }; + std::unique_ptr _graph_output{ nullptr }; + std::unique_ptr _current_node{ nullptr }; + ITensorObject *_current_output{ nullptr }; + bool _info_enabled{ false }; private: - Tensor *_current_input{ nullptr }; - GraphHints _previous_hints{}; + ITensorObject *_current_input{ nullptr }; + GraphHints _previous_hints{}; }; Graph::~Graph() //NOLINT @@ -78,7 +81,7 @@ void Graph::run() { while(true) { - if(!_pimpl->_graph_input->call_accessor()) + if(_pimpl->_graph_input->has_accessor() && !_pimpl->_graph_input->call_accessor()) { return; } @@ -88,7 +91,8 @@ void Graph::run() stage._function->run(); } - if(!_pimpl->_graph_output->call_accessor()) + if((_pimpl->_graph_output->has_accessor() && !_pimpl->_graph_output->call_accessor()) + || (!_pimpl->_graph_output->has_accessor())) { return; } @@ -126,9 +130,11 @@ void Graph::Private::configure(GraphHints _next_hints) _current_output->set_target(TargetHint::NEON); } - // Update ctx and instantiate node + // Instantiate Node _ctx.hints() = _current_hints; - std::unique_ptr func = _current_node->instantiate_node(_ctx, _current_input->tensor(), _current_output->tensor()); + std::unique_ptr func = _current_node->instantiate_node(_ctx, _current_input, _current_output); + + // Allocate current input _current_input->allocate(); // Map input if needed @@ -181,7 +187,7 @@ void Graph::add_node(std::unique_ptr node) } //Add a tensor with an Accessor (i.e either the input or output of the graph) -void Graph::add_tensor(std::unique_ptr tensor) +void Graph::add_tensor_object(std::unique_ptr tensor) { // If it's the first Tensor added then it will be the input of the Graph. if(_pimpl->_graph_input == nullptr) @@ -227,7 +233,13 @@ Graph &arm_compute::graph::operator<<(Graph &graph, TensorInfo &&info) Graph &arm_compute::graph::operator<<(Graph &graph, Tensor &&tensor) { - graph.add_tensor(arm_compute::support::cpp14::make_unique(std::move(tensor))); + graph.add_tensor_object(arm_compute::support::cpp14::make_unique(std::move(tensor))); + return graph; +} + +Graph &arm_compute::graph::operator<<(Graph &graph, SubTensor &&sub_tensor) +{ + graph.add_tensor_object(arm_compute::support::cpp14::make_unique(std::move(sub_tensor))); return graph; } -- cgit v1.2.1