From 7b87e08dc8dc897af16493ce8c3c976349efbd9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Wed, 21 Nov 2018 17:00:55 +0900 Subject: [PATCH] [neurun] Graph holds Model as pointer (#3663) Graph holds Model as pointer. This is for the next work that `_model` is moved to Linear. Signed-off-by: Hanjoung Lee --- runtimes/neurun/src/graph/Graph.cc | 22 +++++++++++----------- runtimes/neurun/src/graph/Graph.h | 16 ++++++++-------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/runtimes/neurun/src/graph/Graph.cc b/runtimes/neurun/src/graph/Graph.cc index d263fed..cf2d00c 100644 --- a/runtimes/neurun/src/graph/Graph.cc +++ b/runtimes/neurun/src/graph/Graph.cc @@ -42,32 +42,32 @@ Graph::~Graph(void) = default; operand::Index Graph::addOperand(const operand::Shape &shape, const operand::TypeInfo &type) { - return _model.operands.append(shape, type); + return _model->operands.append(shape, type); } operation::Index Graph::addOperation(std::unique_ptr &&node) { assert(isBuildingPhase()); - return _model.operations.append(std::move(node)); + return _model->operations.append(std::move(node)); } void Graph::setOperandValue(const operand::Index &ind, std::unique_ptr &&data) { assert(isBuildingPhase()); - assert(_model.operands.exist(ind)); - _model.operands.at(ind).data(std::move(data)); + assert(_model->operands.exist(ind)); + _model->operands.at(ind).data(std::move(data)); } void Graph::addInput(const operand::Index &ind) { assert(isBuildingPhase()); - _model.inputs.append(ind); + _model->inputs.append(ind); } void Graph::addOutput(const operand::Index &ind) { assert(isBuildingPhase()); - _model.outputs.append(ind); + _model->outputs.append(ind); } void Graph::finishBuilding(void) @@ -94,14 +94,14 @@ void Graph::lower(void) // operand::LowerInfo holder std::unordered_map> operands_lower_info; - _model.operands.iterate([&](const operand::Index &index, const operand::Object &object) { + _model->operands.iterate([&](const operand::Index &index, const operand::Object &object) { operands_lower_info[index] = nnfw::make_unique(operand::asShape4D(object.shape())); }); - _backend_resolver = nnfw::make_unique(_model.operands); + _backend_resolver = nnfw::make_unique(_model->operands); - _model.operations.iterate([&](const operation::Index &, operation::Node &node) { + _model->operations.iterate([&](const operation::Index &, operation::Node &node) { auto backend = _backend_resolver->getBackend(typeid(node)); // Operation LowerInfo @@ -135,7 +135,7 @@ void Graph::lower(void) // Add DefBackend constants same as UseBackend // NOTE This assumes a constant operand is used by only one operation - _model.operations.iterate([&](const operation::Index &, operation::Node &node) { + _model->operations.iterate([&](const operation::Index &, operation::Node &node) { // LowerInfo for input operands for (auto operand : node.getInputs()) { @@ -148,7 +148,7 @@ void Graph::lower(void) }); // Set LowerInfo for each operand from the operand::LowerInfo holder - _model.operands.iterate([&](const operand::Index &index, operand::Object &object) { + _model->operands.iterate([&](const operand::Index &index, operand::Object &object) { object.lower_info(std::move(operands_lower_info[index])); // Dump operand LowerInfo diff --git a/runtimes/neurun/src/graph/Graph.h b/runtimes/neurun/src/graph/Graph.h index e5ca1ec..3b82a6c 100644 --- a/runtimes/neurun/src/graph/Graph.h +++ b/runtimes/neurun/src/graph/Graph.h @@ -114,18 +114,18 @@ private: // Accessors public: - const operand::IndexSet &getInputs() const { return _model.inputs; } - const operand::IndexSet &getOutputs() const { return _model.outputs; } - operand::IndexSet &getOutputs() { return _model.outputs; } - const operand::Set &operands() const { return _model.operands; } - operand::Set &operands() { return _model.operands; } // TODO Remove this non-const accessor - const operation::Set &operations() const { return _model.operations; } - operation::Set &operations() { return _model.operations; } + const operand::IndexSet &getInputs() const { return _model->inputs; } + const operand::IndexSet &getOutputs() const { return _model->outputs; } + operand::IndexSet &getOutputs() { return _model->outputs; } + const operand::Set &operands() const { return _model->operands; } + operand::Set &operands() { return _model->operands; } // TODO Remove this non-const accessor + const operation::Set &operations() const { return _model->operations; } + operation::Set &operations() { return _model->operations; } const codegen::BackendResolver *backend_resolver() const { return _backend_resolver.get(); } private: Phase _phase{Phase::BUILDING}; - Model _model; + std::unique_ptr _model{new Model}; // For LOWERED phase private: -- 2.7.4