From 4431030fc41b8231504f98f447a2f0b62172b4d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 18 Jul 2019 13:40:07 +0900 Subject: [PATCH] Rename SubgraphContext (#5679) Rename `SubgraphContext` to `Subgraphs` so it follows the naming rule like `Operations` and `Operands`. Variable name `subg_ctx` is also replaced with `subgraphs`. Signed-off-by: Hanjoung Lee --- runtimes/neurun/core/include/graph/Graph.h | 16 ++++++++-------- .../include/model/{SubgraphContext.h => Subgraphs.h} | 2 +- runtimes/neurun/core/src/compiler/ExecutorFactory.cc | 12 ++++++------ runtimes/neurun/core/src/dumper/dot/DotDumper.cc | 6 +++--- runtimes/neurun/core/src/exec/DataflowExecutor.cc | 18 +++++++++--------- runtimes/neurun/core/src/exec/DataflowExecutor.h | 2 +- runtimes/neurun/core/src/exec/ExecutorBase.cc | 4 ++-- runtimes/neurun/core/src/exec/ExecutorBase.h | 6 +++--- runtimes/neurun/core/src/exec/LinearExecutor.h | 4 ++-- runtimes/neurun/core/src/exec/ParallelExecutor.cc | 4 ++-- runtimes/neurun/core/src/exec/ParallelExecutor.h | 2 +- runtimes/neurun/core/src/graph/Graph.cc | 18 +++++++++--------- .../core/src/graph/pass/PermutationEliminationPass.cc | 12 ++++++------ .../core/src/graph/pass/PermutationInsertionPass.cc | 12 ++++++------ runtimes/neurun/core/src/linear/Linear.cc | 18 +++++++++--------- runtimes/neurun/core/src/linear/Linear.h | 8 ++++---- .../src/model/{SubgraphContext.cc => Subgraphs.cc} | 15 +++++++-------- 17 files changed, 79 insertions(+), 80 deletions(-) rename runtimes/neurun/core/include/model/{SubgraphContext.h => Subgraphs.h} (96%) rename runtimes/neurun/core/src/model/{SubgraphContext.cc => Subgraphs.cc} (74%) diff --git a/runtimes/neurun/core/include/graph/Graph.h b/runtimes/neurun/core/include/graph/Graph.h index de15018..d1ef4bf 100644 --- a/runtimes/neurun/core/include/graph/Graph.h +++ b/runtimes/neurun/core/include/graph/Graph.h @@ -23,7 +23,7 @@ #include "model/Model.h" #include "graph/LowerInfoMap.h" #include "model/Subgraph.h" -#include "model/SubgraphContext.h" +#include "model/Subgraphs.h" namespace neurun { @@ -126,7 +126,7 @@ public: bool isBuildingPhase(void) const { return _phase == Phase::BUILDING; } std::shared_ptr shareModel() { return _model; } std::unique_ptr releaseLowerInfo() { return std::move(_lower_info_map); } - std::unique_ptr releaseSubgraphContext() { return std::move(_subg_ctx); } + std::unique_ptr releaseSubgraphs() { return std::move(_subgraphs); } private: void initializeUseDef(); @@ -156,19 +156,19 @@ public: operand::LowerInfo *getLowerInfo(const model::OperandIndex &index); void setLowerInfo(const model::OperandIndex &index, std::unique_ptr &&lower_info); - model::SubgraphContext &subg_ctx() + model::Subgraphs &subgraphs() { - assert(_subg_ctx); - return *_subg_ctx; + assert(_subgraphs); + return *_subgraphs; } - const model::SubgraphContext *subg_ctx() const { return _subg_ctx.get(); } + const model::Subgraphs *subgraphs() const { return _subgraphs.get(); } void setBackendResolver(std::unique_ptr &&br); private: std::unique_ptr _backend_resolver; std::unique_ptr _lower_info_map; - // Pass(for Perm) can accept only graph so that Graph has SubgraphContext as a member - std::unique_ptr _subg_ctx; + // Pass(for Perm) can accept only graph so that Graph has Subgraphs as a member + std::unique_ptr _subgraphs; }; } // namespace graph diff --git a/runtimes/neurun/core/include/model/SubgraphContext.h b/runtimes/neurun/core/include/model/Subgraphs.h similarity index 96% rename from runtimes/neurun/core/include/model/SubgraphContext.h rename to runtimes/neurun/core/include/model/Subgraphs.h index 582bd19..8e5a0f0 100644 --- a/runtimes/neurun/core/include/model/SubgraphContext.h +++ b/runtimes/neurun/core/include/model/Subgraphs.h @@ -29,7 +29,7 @@ namespace model /** * @brief Class that manages Subgraph objects */ -class SubgraphContext : public util::ObjectManager +class Subgraphs : public util::ObjectManager { public: /** diff --git a/runtimes/neurun/core/src/compiler/ExecutorFactory.cc b/runtimes/neurun/core/src/compiler/ExecutorFactory.cc index 68086ea..e76088e 100644 --- a/runtimes/neurun/core/src/compiler/ExecutorFactory.cc +++ b/runtimes/neurun/core/src/compiler/ExecutorFactory.cc @@ -118,7 +118,7 @@ exec::IExecutor *ExecutorFactory::createLinearExecutor(graph::Graph &graph) auto plan = std::make_shared(function_sequence); return new exec::LinearExecutor{graph.shareModel(), - linear->releaseSubgraphContext(), + linear->releaseSubgraphs(), operand_context, linear->releaseLowerInfo(), std::move(mem_mgrs), @@ -130,13 +130,13 @@ exec::IExecutor *ExecutorFactory::createDataflowExecutor(graph::Graph &graph, bo { auto operand_context = std::make_shared(); - graph.subg_ctx().iterate([&](const model::SubgraphIndex &, const model::Subgraph &subg) { + graph.subgraphs().iterate([&](const model::SubgraphIndex &, const model::Subgraph &subg) { auto subtensor_analyzer = SubTensorAnalyzer{graph.operands()}; subg.accept(subtensor_analyzer); }); // Fix shapes - graph.subg_ctx().iterate( + graph.subgraphs().iterate( [&](const model::SubgraphIndex &subg_index, const model::Subgraph &subg) { auto backend = graph.getLowerInfo(subg_index)->backend(); auto shape_fixer = backend->shape_fixer(); @@ -218,7 +218,7 @@ exec::IExecutor *ExecutorFactory::createDataflowExecutor(graph::Graph &graph, bo auto execution_builder = nnfw::cpp14::make_unique(); // Generate kernels - graph.subg_ctx().iterate( + graph.subgraphs().iterate( [&](const model::SubgraphIndex &subg_index, const model::Subgraph &subg) { auto backend = graph.getLowerInfo(subg_index)->backend(); // TODO This approach is temporal. See declaration of `setNextIndex`. @@ -246,14 +246,14 @@ exec::IExecutor *ExecutorFactory::createDataflowExecutor(graph::Graph &graph, bo if (parallel) { return new exec::ParallelExecutor{ - graph.shareModel(), std::move(graph.releaseSubgraphContext()), + graph.shareModel(), std::move(graph.releaseSubgraphs()), operand_context, std::move(lower_info), std::move(mem_mgrs), std::move(execution_builder->releaseCodeMap())}; } else { auto exec = new exec::DataflowExecutor{ - graph.shareModel(), std::move(graph.releaseSubgraphContext()), + graph.shareModel(), std::move(graph.releaseSubgraphs()), operand_context, std::move(lower_info), std::move(mem_mgrs), std::move(execution_builder->releaseCodeMap())}; if (util::getConfigBool(util::config::PROFILING_MODE)) diff --git a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc index 7c8bc67..91ca054 100644 --- a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc +++ b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc @@ -102,10 +102,10 @@ void DotDumper::dumpIfNeeded(const std::string &tag) } }); - const auto subg_ctx = _graph.subg_ctx(); - if (subg_ctx) + const auto subgraphs = _graph.subgraphs(); + if (subgraphs) { - subg_ctx->iterate([&](const model::SubgraphIndex &index, const model::Subgraph &subgraph) { + subgraphs->iterate([&](const model::SubgraphIndex &index, const model::Subgraph &subgraph) { DotSubgraphInfo subgraph_info{index, subgraph, shown_operand_set}; dot_builder.addSubgraph(subgraph_info); for (const auto &op : subgraph.operations()) diff --git a/runtimes/neurun/core/src/exec/DataflowExecutor.cc b/runtimes/neurun/core/src/exec/DataflowExecutor.cc index 6c02c91..5e87547 100644 --- a/runtimes/neurun/core/src/exec/DataflowExecutor.cc +++ b/runtimes/neurun/core/src/exec/DataflowExecutor.cc @@ -53,7 +53,7 @@ void DataflowExecutor::emplaceToReadyJobs(const uint32_t &id) { auto &job = _waiting_jobs[id]; assert(job != nullptr); - auto &subg = _subg_ctx->at(_job_to_subgraph[job->index()]); + auto &subg = _subgraphs->at(_job_to_subgraph[job->index()]); auto rank = calculateRank(subg.operations()); _ready_jobs.emplace(rank, std::move(job)); } @@ -77,22 +77,22 @@ bool DataflowExecutor::noWaitingJobs() } DataflowExecutor::DataflowExecutor(const std::shared_ptr &model, - std::unique_ptr subg_ctx, + std::unique_ptr subgraphs, const std::shared_ptr &operand_context, std::unique_ptr lower_info, std::unique_ptr mem_mgrs, CodeMap &&code_map) - : ExecutorBase{model, std::move(subg_ctx), operand_context, std::move(lower_info), + : ExecutorBase{model, std::move(subgraphs), operand_context, std::move(lower_info), std::move(mem_mgrs)}, _code_map{std::move(code_map)} { VERBOSE(DataflowExecutor) << "Constructing Dataflow Executor" << std::endl; - assert(_subg_ctx); + assert(_subgraphs); // Assign jobs convert SubgraphIndex to job index(uint32_t) uint32_t next_job_index = 0; std::unordered_map subgraph_to_job; - _subg_ctx->iterate([&](const model::SubgraphIndex &subg_index, const model::Subgraph &) { + _subgraphs->iterate([&](const model::SubgraphIndex &subg_index, const model::Subgraph &) { VERBOSE(DataflowExecutor) << "Create a job #" << next_job_index << " with SubgraphIndex " << subg_index.value() << std::endl; _finished_jobs.emplace_back( @@ -105,12 +105,12 @@ DataflowExecutor::DataflowExecutor(const std::shared_ptr &mo _output_info.resize(next_job_index); _initial_input_info.resize(next_job_index, 0); - _subg_ctx->iterate([&](const model::SubgraphIndex &subg_index, const model::Subgraph &subg) { + _subgraphs->iterate([&](const model::SubgraphIndex &subg_index, const model::Subgraph &subg) { auto job_index = subgraph_to_job[subg_index]; for (auto output : subg.getOutputs()) { // Update output and input info - _subg_ctx->iterate( + _subgraphs->iterate( [&](const model::SubgraphIndex &subg_cur_index, const model::Subgraph &subg_cur) { if (subg_cur.getInputs().contains(output)) { @@ -174,7 +174,7 @@ void DataflowExecutor::notifyJobBegin(uint32_t job_index) { auto subgraph_index = _job_to_subgraph[job_index]; // Workaround - assumes only one operation - auto node = _subg_ctx->at(subgraph_index).operations().at(0).node; + auto node = _subgraphs->at(subgraph_index).operations().at(0).node; const backend::Backend *backend = _lower_info->operation.at(subgraph_index)->backend(); for (auto &o : _observers) { @@ -186,7 +186,7 @@ void DataflowExecutor::notifyJobEnd(uint32_t job_index) { auto subgraph_index = _job_to_subgraph[job_index]; // Workaround - assumes only one operation - auto node = _subg_ctx->at(subgraph_index).operations().at(0).node; + auto node = _subgraphs->at(subgraph_index).operations().at(0).node; const backend::Backend *backend = _lower_info->operation.at(subgraph_index)->backend(); for (auto &o : _observers) { diff --git a/runtimes/neurun/core/src/exec/DataflowExecutor.h b/runtimes/neurun/core/src/exec/DataflowExecutor.h index ab21893..70c06bc 100644 --- a/runtimes/neurun/core/src/exec/DataflowExecutor.h +++ b/runtimes/neurun/core/src/exec/DataflowExecutor.h @@ -54,7 +54,7 @@ public: * @param ranks Operation ranks for ordering execution */ DataflowExecutor(const std::shared_ptr &model, - std::unique_ptr subg_ctx, + std::unique_ptr subgraphs, const std::shared_ptr &operand_context, std::unique_ptr lower_info, std::unique_ptr mem_mgrs, CodeMap &&code_map); diff --git a/runtimes/neurun/core/src/exec/ExecutorBase.cc b/runtimes/neurun/core/src/exec/ExecutorBase.cc index 480dfad..21de8b3 100644 --- a/runtimes/neurun/core/src/exec/ExecutorBase.cc +++ b/runtimes/neurun/core/src/exec/ExecutorBase.cc @@ -22,11 +22,11 @@ namespace exec { ExecutorBase::ExecutorBase(const std::shared_ptr &model, - std::unique_ptr subg_ctx, + std::unique_ptr subgraphs, const std::shared_ptr &operand_context, std::unique_ptr lower_info, std::unique_ptr mem_mgrs) - : _observers(), _model{model}, _subg_ctx{std::move(subg_ctx)}, + : _observers(), _model{model}, _subgraphs{std::move(subgraphs)}, _operand_context{operand_context}, _lower_info{std::move(lower_info)}, _mem_mgrs{std::move(mem_mgrs)} { diff --git a/runtimes/neurun/core/src/exec/ExecutorBase.h b/runtimes/neurun/core/src/exec/ExecutorBase.h index cf6d7df..46c2885 100644 --- a/runtimes/neurun/core/src/exec/ExecutorBase.h +++ b/runtimes/neurun/core/src/exec/ExecutorBase.h @@ -27,7 +27,7 @@ #include "model/OperandInfo.h" #include "backend/Backend.h" #include "compiler/OperandContext.h" -#include "model/SubgraphContext.h" +#include "model/Subgraphs.h" #include "model/Subgraph.h" #include "backend/ExecTime.h" #include "exec/IFunction.h" @@ -43,7 +43,7 @@ class ExecutorBase : public IExecutor { public: ExecutorBase(const std::shared_ptr &model, - std::unique_ptr subg_ctx, + std::unique_ptr subgraphs, const std::shared_ptr &operand_context, std::unique_ptr lower_info, std::unique_ptr mem_mgrs); @@ -135,7 +135,7 @@ protected: std::list> _observers; std::shared_ptr> _indexed_ranks; std::shared_ptr _model; - std::unique_ptr _subg_ctx; + std::unique_ptr _subgraphs; std::shared_ptr _operand_context; std::unique_ptr _lower_info; std::unique_ptr _mem_mgrs; diff --git a/runtimes/neurun/core/src/exec/LinearExecutor.h b/runtimes/neurun/core/src/exec/LinearExecutor.h index 36e429d..403a426 100644 --- a/runtimes/neurun/core/src/exec/LinearExecutor.h +++ b/runtimes/neurun/core/src/exec/LinearExecutor.h @@ -43,13 +43,13 @@ public: * @param[in] plan Execution plan generated by compiled result */ LinearExecutor(const std::shared_ptr &model, - std::unique_ptr subg_ctx, + std::unique_ptr subgraphs, const std::shared_ptr &operand_context, std::unique_ptr lower_info, std::unique_ptr mem_mgrs, std::unique_ptr> elements, const std::shared_ptr &plan) - : ExecutorBase{model, std::move(subg_ctx), operand_context, std::move(lower_info), + : ExecutorBase{model, std::move(subgraphs), operand_context, std::move(lower_info), std::move(mem_mgrs)}, _plan{plan}, _elements{std::move(elements)} { diff --git a/runtimes/neurun/core/src/exec/ParallelExecutor.cc b/runtimes/neurun/core/src/exec/ParallelExecutor.cc index 512162f..b0a7f80 100644 --- a/runtimes/neurun/core/src/exec/ParallelExecutor.cc +++ b/runtimes/neurun/core/src/exec/ParallelExecutor.cc @@ -55,13 +55,13 @@ void ParallelExecutor::notify(uint32_t finished_job_id) } ParallelExecutor::ParallelExecutor(const std::shared_ptr &model, - std::unique_ptr subg_ctx, + std::unique_ptr subgraphs, const std::shared_ptr &operand_context, std::unique_ptr lower_info, std::unique_ptr mem_mgrs, CodeMap &&code_map) : DataflowExecutor{model, - std::move(subg_ctx), + std::move(subgraphs), operand_context, std::move(lower_info), std::move(mem_mgrs), diff --git a/runtimes/neurun/core/src/exec/ParallelExecutor.h b/runtimes/neurun/core/src/exec/ParallelExecutor.h index 61793d8..ff86bc5 100644 --- a/runtimes/neurun/core/src/exec/ParallelExecutor.h +++ b/runtimes/neurun/core/src/exec/ParallelExecutor.h @@ -54,7 +54,7 @@ public: * @param ranks Operation ranks for ordering execution */ ParallelExecutor(const std::shared_ptr &model, - std::unique_ptr subg_ctx, + std::unique_ptr subgraphs, const std::shared_ptr &operand_context, std::unique_ptr lower_info, std::unique_ptr mem_mgrs, CodeMap &&code_map); diff --git a/runtimes/neurun/core/src/graph/Graph.cc b/runtimes/neurun/core/src/graph/Graph.cc index bc31d74..74e8fa8 100644 --- a/runtimes/neurun/core/src/graph/Graph.cc +++ b/runtimes/neurun/core/src/graph/Graph.cc @@ -93,7 +93,7 @@ void Graph::lower(void) { assert(_phase == Phase::MODEL); - _subg_ctx = nnfw::cpp14::make_unique(); + _subgraphs = nnfw::cpp14::make_unique(); bool is_profiling = util::getConfigBool(util::config::PROFILING_MODE); // Lower @@ -113,7 +113,7 @@ void Graph::lower(void) // 2. if 1 is true, the subg and a node are connected? auto mergeable = [&](const model::SubgraphIndex &subg_index, const model::OperationIndex &node_index) { - const auto &subg = _subg_ctx->at(subg_index); + const auto &subg = _subgraphs->at(subg_index); const auto &node = _model->operations.at(node_index); // The same backend id? @@ -179,8 +179,8 @@ void Graph::lower(void) auto make_subgraph = [&](const model::OperationIndex &node_index, const model::Operation &node, model::Layout layout) { - auto subg_index = _subg_ctx->emplace(node_index, node, layout); - auto &subg = _subg_ctx->at(subg_index); + auto subg_index = _subgraphs->emplace(node_index, node, layout); + auto &subg = _subgraphs->at(subg_index); subg.setOutputs(node.getOutputs()); subg.setInputs(node.getInputs()); return subg_index; @@ -236,7 +236,7 @@ void Graph::lower(void) nnfw::cpp14::make_unique(backend)); subg_index = new_subg_index; - subg = &(_subg_ctx->at(new_subg_index)); + subg = &(_subgraphs->at(new_subg_index)); VERBOSE(Lower) << "SUBG#" << subg_index.value() << " is created for " << "NODE#" << node_index.value() << "(" << node.getName() << ")" @@ -301,12 +301,12 @@ void Graph::lower(void) subg = nullptr; }); - _subg_ctx->iterate([&](const model::SubgraphIndex &, model::Subgraph &subg) { + _subgraphs->iterate([&](const model::SubgraphIndex &, model::Subgraph &subg) { assert(subg.operations().size() > 0); std::reverse(std::begin(subg.operations()), std::end(subg.operations())); }); - _subg_ctx->dump("merged and sorted operations without permutation"); + _subgraphs->dump("merged and sorted operations without permutation"); // NOTE This is desired way to handle model input and outputs however getDefaultBackend() is // cpu backend dependent for now we cannot use it. @@ -432,7 +432,7 @@ void Graph::lower(void) // pe_pass.run(); // TODO merge perm subgraphs if possible - _subg_ctx->dump("merged and sorted operations with permutation"); + _subgraphs->dump("merged and sorted operations with permutation"); } // Graph verifications for the LOWERED phase @@ -446,7 +446,7 @@ std::unique_ptr Graph::linearize(void) { assert(_phase == Phase::MODEL); - auto linear = nnfw::cpp14::make_unique(shareModel(), releaseSubgraphContext(), + auto linear = nnfw::cpp14::make_unique(shareModel(), releaseSubgraphs(), releaseLowerInfo()); // TODO Move the operations and operands to linear object diff --git a/runtimes/neurun/core/src/graph/pass/PermutationEliminationPass.cc b/runtimes/neurun/core/src/graph/pass/PermutationEliminationPass.cc index 3ad7324..6af153b 100644 --- a/runtimes/neurun/core/src/graph/pass/PermutationEliminationPass.cc +++ b/runtimes/neurun/core/src/graph/pass/PermutationEliminationPass.cc @@ -79,9 +79,9 @@ void PermutationEliminationPass::eliminateInput(const model::OperandIndex &inp_i _graph.removeOperand(inp_index); // remove permutation operation - assert(_graph.subg_ctx().containsOperation(input_use)); - auto subg_idx = _graph.subg_ctx().findOperation(input_use); - _graph.subg_ctx().remove(subg_idx); + assert(_graph.subgraphs().containsOperation(input_use)); + auto subg_idx = _graph.subgraphs().findOperation(input_use); + _graph.subgraphs().remove(subg_idx); _graph.operations().remove(input_use); VERBOSE(PermutationEliminationPass::EliminateInput) @@ -134,9 +134,9 @@ void PermutationEliminationPass::eliminateOutput(const model::OperandIndex &out_ _graph.removeOperand(out_index); // remove permutation operation - assert(_graph.subg_ctx().containsOperation(output_def)); - auto subg_idx = _graph.subg_ctx().findOperation(output_def); - _graph.subg_ctx().remove(subg_idx); + assert(_graph.subgraphs().containsOperation(output_def)); + auto subg_idx = _graph.subgraphs().findOperation(output_def); + _graph.subgraphs().remove(subg_idx); _graph.operations().remove(output_def); VERBOSE(PermutationEliminationPass::EliminateOutput) diff --git a/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.cc b/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.cc index 2f65dfa..02655d8 100644 --- a/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.cc +++ b/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.cc @@ -85,11 +85,11 @@ void PermutationInsertionPass::callback(const model::OperandIndex &index, model: continue; auto &operation = _graph.operations().at(use); - assert(_graph.subg_ctx().containsOperation(use)); - auto subg_index = _graph.subg_ctx().findOperation(use); + assert(_graph.subgraphs().containsOperation(use)); + auto subg_index = _graph.subgraphs().findOperation(use); auto subg_li = _graph.getLowerInfo(subg_index); assert(subg_li); - const auto subg_layout = _graph.subg_ctx().at(subg_index).getLayout(); + const auto subg_layout = _graph.subgraphs().at(subg_index).getLayout(); const backend::Backend *backend = subg_li->backend(); assert(backend); auto use_node_inputs = operation.getInputs(); @@ -99,7 +99,7 @@ void PermutationInsertionPass::callback(const model::OperandIndex &index, model: if (index != new_index) { // Update from subgraph - _graph.subg_ctx().at(subg_index).replaceInput(index, new_index); + _graph.subgraphs().at(subg_index).replaceInput(index, new_index); // Update from operation operation.replaceInput(index, new_index); @@ -174,8 +174,8 @@ PermutationInsertionPass::insertPermute(const model::OperandIndex &operand_index // Subgraph { - auto subg_index = _graph.subg_ctx().emplace(node_index, node, permute_node_layout); - auto &subg = _graph.subg_ctx().at(subg_index); + auto subg_index = _graph.subgraphs().emplace(node_index, node, permute_node_layout); + auto &subg = _graph.subgraphs().at(subg_index); subg.setInputs(node.getInputs()); subg.setOutputs(node.getOutputs()); _graph.setLowerInfo( diff --git a/runtimes/neurun/core/src/linear/Linear.cc b/runtimes/neurun/core/src/linear/Linear.cc index cf4ebd2..959d4b3 100644 --- a/runtimes/neurun/core/src/linear/Linear.cc +++ b/runtimes/neurun/core/src/linear/Linear.cc @@ -35,17 +35,17 @@ namespace linear { Linear::Linear(const std::shared_ptr &model, - std::unique_ptr subg_ctx, + std::unique_ptr subgraphs, std::unique_ptr lower_info_map) - : _model(model), _subg_ctx{std::move(subg_ctx)}, _lower_info_map{std::move(lower_info_map)} + : _model(model), _subgraphs{std::move(subgraphs)}, _lower_info_map{std::move(lower_info_map)} { - assert(_model && _subg_ctx && _lower_info_map); + assert(_model && _subgraphs && _lower_info_map); _elements = nnfw::cpp14::make_unique>(); // Get SubgraphSequence by topological sorting { - // _subg_ctx can't access a subgraph by an operand so that input_to_subgs can offer it + // _subgraphs can't access a subgraph by an operand so that input_to_subgs can offer it std::unordered_map> input_to_subgs; // Get the relations between input/subgraph to be used for dfs-post-iter @@ -63,7 +63,7 @@ Linear::Linear(const std::shared_ptr &model, // [SUBG3] // | // [4] - _subg_ctx->iterate([&](const model::SubgraphIndex &subg_idx, model::Subgraph &subg) { + _subgraphs->iterate([&](const model::SubgraphIndex &subg_idx, model::Subgraph &subg) { for (auto input : subg.getInputs()) { // only valid_inputs @@ -85,7 +85,7 @@ Linear::Linear(const std::shared_ptr &model, }); std::unordered_map visited; - _subg_ctx->iterate([&](const model::SubgraphIndex &index, const model::Subgraph &) { + _subgraphs->iterate([&](const model::SubgraphIndex &index, const model::Subgraph &) { visited[index] = false; }); @@ -104,16 +104,16 @@ Linear::Linear(const std::shared_ptr &model, const auto &subg_index_list = it->second; for (const auto &index : subg_index_list) { - auto &subg = _subg_ctx->at(index); + auto &subg = _subgraphs->at(index); dfs_recursive(index, subg); } } } - _elements->emplace_back(&_subg_ctx->at(index), getLowerInfo(index)); + _elements->emplace_back(&_subgraphs->at(index), getLowerInfo(index)); }; - _subg_ctx->iterate(dfs_recursive); + _subgraphs->iterate(dfs_recursive); // All of the nodes must have been visited. assert( diff --git a/runtimes/neurun/core/src/linear/Linear.h b/runtimes/neurun/core/src/linear/Linear.h index ceb784f..ed82c48 100644 --- a/runtimes/neurun/core/src/linear/Linear.h +++ b/runtimes/neurun/core/src/linear/Linear.h @@ -22,7 +22,7 @@ #include "Element.h" #include "model/Model.h" -#include "model/SubgraphContext.h" +#include "model/Subgraphs.h" #include "backend/ITensorBuilder.h" #include "graph/LowerInfoMap.h" @@ -46,7 +46,7 @@ class Linear { public: Linear(const std::shared_ptr &model, - std::unique_ptr subg_ctx, + std::unique_ptr subgraphs, std::unique_ptr lower_info_map); public: @@ -63,7 +63,7 @@ public: std::unique_ptr releaseLowerInfo() { return std::move(_lower_info_map); } graph::LowerInfoMap *getLowerInfo() { return _lower_info_map.get(); } - std::unique_ptr releaseSubgraphContext() { return std::move(_subg_ctx); } + std::unique_ptr releaseSubgraphs() { return std::move(_subgraphs); } std::unique_ptr> releaseElements() { return std::move(_elements); } @@ -74,7 +74,7 @@ private: private: std::shared_ptr _model; - std::unique_ptr _subg_ctx; + std::unique_ptr _subgraphs; std::unique_ptr _lower_info_map; std::unique_ptr> _elements; }; diff --git a/runtimes/neurun/core/src/model/SubgraphContext.cc b/runtimes/neurun/core/src/model/Subgraphs.cc similarity index 74% rename from runtimes/neurun/core/src/model/SubgraphContext.cc rename to runtimes/neurun/core/src/model/Subgraphs.cc index 12842e9..ed89fb1 100644 --- a/runtimes/neurun/core/src/model/SubgraphContext.cc +++ b/runtimes/neurun/core/src/model/Subgraphs.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "model/SubgraphContext.h" +#include "model/Subgraphs.h" #include "util/logging.h" #include "cpp14/memory.h" @@ -26,15 +26,14 @@ namespace neurun namespace model { -SubgraphIndex SubgraphContext::emplace(const OperationIndex &index, const Operation &node, - Layout layout) +SubgraphIndex Subgraphs::emplace(const OperationIndex &index, const Operation &node, Layout layout) { std::unique_ptr subg = nnfw::cpp14::make_unique(layout); subg->appendOperation(index, node); return push(std::move(subg)); } -bool SubgraphContext::containsOperation(const OperationIndex &operation_index) const +bool Subgraphs::containsOperation(const OperationIndex &operation_index) const { bool ret = false; iterate([&](const SubgraphIndex &, const Subgraph &object) { @@ -47,7 +46,7 @@ bool SubgraphContext::containsOperation(const OperationIndex &operation_index) c return ret; } -SubgraphIndex SubgraphContext::findOperation(const OperationIndex &operation_index) const +SubgraphIndex Subgraphs::findOperation(const OperationIndex &operation_index) const { SubgraphIndex ret; iterate([&](const SubgraphIndex &index, const Subgraph &object) { @@ -62,11 +61,11 @@ SubgraphIndex SubgraphContext::findOperation(const OperationIndex &operation_ind } // TODO: Extract this into external helper function -void SubgraphContext::dump(const std::string &msg) const +void Subgraphs::dump(const std::string &msg) const { - VERBOSE(SubgraphContext) << "SubgraphContext(" << msg << ")" << std::endl; + VERBOSE(Subgraphs) << "Subgraphs(" << msg << ")" << std::endl; iterate([&](const SubgraphIndex &idx, const model::Subgraph &subg) { - VERBOSE(SubgraphContext) << idx.value() << "] " << subg.getStr() << std::endl; + VERBOSE(Subgraphs) << idx.value() << "] " << subg.getStr() << std::endl; }); } -- 2.7.4