diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-10-02 18:51:47 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | e2c82fee3b6d38f6e79412c78176792b817defd0 (patch) | |
tree | aa6821e33cfe8001c33086191c81c18d66ac7837 /src/graph/Graph.cpp | |
parent | 48a60f9f7b0b7b5cf38253b7a2ac576aac43ef78 (diff) | |
download | ComputeLibrary-e2c82fee3b6d38f6e79412c78176792b817defd0.tar.gz |
COMPMID-550: Adds support for branches.
Change-Id: I778007c9221ce3156400284c4039b90245eb2b7f
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/90043
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/graph/Graph.cpp')
-rw-r--r-- | src/graph/Graph.cpp | 52 |
1 files changed, 32 insertions, 20 deletions
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<arm_compute::IFunction> _function; }; @@ -48,20 +50,21 @@ public: */ void configure(GraphHints _next_hints); - GraphContext _ctx{}; - std::vector<Stage> _pipeline{}; - std::vector<std::unique_ptr<Tensor>> _tensors{}; - std::vector<std::unique_ptr<INode>> _nodes{}; - GraphHints _current_hints{}; - GraphHints _next_hints{}; - std::unique_ptr<Tensor> _graph_input{ nullptr }; - std::unique_ptr<Tensor> _graph_output{ nullptr }; - std::unique_ptr<INode> _current_node{ nullptr }; - Tensor *_current_output{ nullptr }; + GraphContext _ctx{}; + std::vector<Stage> _pipeline{}; + std::vector<std::unique_ptr<ITensorObject>> _tensors{}; + std::vector<std::unique_ptr<INode>> _nodes{}; + GraphHints _current_hints{}; + GraphHints _next_hints{}; + std::unique_ptr<ITensorObject> _graph_input{ nullptr }; + std::unique_ptr<ITensorObject> _graph_output{ nullptr }; + std::unique_ptr<INode> _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<arm_compute::IFunction> func = _current_node->instantiate_node(_ctx, _current_input->tensor(), _current_output->tensor()); + std::unique_ptr<arm_compute::IFunction> 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<INode> 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> tensor) +void Graph::add_tensor_object(std::unique_ptr<ITensorObject> 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<Tensor>(std::move(tensor))); + graph.add_tensor_object(arm_compute::support::cpp14::make_unique<Tensor>(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<SubTensor>(std::move(sub_tensor))); return graph; } |