From: 이한종/On-Device Lab(SR)/Engineer/삼성전자 Date: Thu, 28 Nov 2019 01:57:31 +0000 (+0900) Subject: [neurun] Dump Operand in order of OperandIndex (#9254) X-Git-Tag: submit/tizen/20191205.083104~90 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a171956405259c91264df4f0612e9eda11c28056;p=platform%2Fcore%2Fml%2Fnnfw.git [neurun] Dump Operand in order of OperandIndex (#9254) `Graph::lower` dumps operands but its order is random since it iterates over the unordered container. This commit makes it to dump in the order of operand index. Signed-off-by: Hanjoung Lee --- diff --git a/runtime/neurun/core/src/graph/Graph.cc b/runtime/neurun/core/src/graph/Graph.cc index 585e8fe..89ff907 100644 --- a/runtime/neurun/core/src/graph/Graph.cc +++ b/runtime/neurun/core/src/graph/Graph.cc @@ -18,6 +18,7 @@ #include #include +#include #include "util/logging.h" #include "verifier/Verifier.h" @@ -425,9 +426,10 @@ void Graph::dumpLowerInfo() if (::neurun::util::logging::ctx.enabled() == false) return; + std::map dumps; + _model->operands.iterate([&](const model::OperandIndex &index, model::Operand &object) { - // Dump operand LowerInfo - // TODO Extract this dumping procedure to be reusable + std::stringstream sstream; if (!getLowerInfo(index)->def_factors().empty() || !getLowerInfo(index)->use_factors().empty()) { auto factors_to_string = [](const operand::PermuteFactorSet &factors) { @@ -458,22 +460,31 @@ void Graph::dumpLowerInfo() std::string use_ops = operation_index_to_string(object.getUses()); std::string def_layouts = factors_to_string(lower_info->def_factors()); std::string use_layouts = factors_to_string(lower_info->use_factors()); - VERBOSE(Lower) << "* Operand #" << index.value() << " LowerInfo" << std::endl; - VERBOSE(Lower) << " - Shape : { " << (shape.rank() > 0 ? shape.dim(0) : 0) << " " - << (shape.rank() > 1 ? shape.dim(1) : 0) << " " - << (shape.rank() > 2 ? shape.dim(2) : 0) << " " - << (shape.rank() > 3 ? shape.dim(3) : 0) << " " - << "}" << std::endl; - VERBOSE(Lower) << " - Def Operations : " << def_ops << std::endl; - VERBOSE(Lower) << " - Use Operations : " << use_ops << std::endl; - VERBOSE(Lower) << " - Lower Info" << std::endl; - VERBOSE(Lower) << " - 4D Shape (NHWC) : { " << lower_shape.n() << " " << lower_shape.h() - << " " << lower_shape.w() << " " << lower_shape.c() << " " - << "}" << std::endl; - VERBOSE(Lower) << " - Def Backends : " << def_layouts << std::endl; - VERBOSE(Lower) << " - Use Backends : " << use_layouts << std::endl; + sstream << "Operand #" << index.value() << " LowerInfo" << std::endl; + sstream << " - Shape : { " << (shape.rank() > 0 ? shape.dim(0) : 0) << " " + << (shape.rank() > 1 ? shape.dim(1) : 0) << " " + << (shape.rank() > 2 ? shape.dim(2) : 0) << " " + << (shape.rank() > 3 ? shape.dim(3) : 0) << " " + << "}" << std::endl; + sstream << " - Def Operations : " << def_ops << std::endl; + sstream << " - Use Operations : " << use_ops << std::endl; + sstream << " - Lower Info" << std::endl; + sstream << " - 4D Shape (NHWC) : { " << lower_shape.n() << " " << lower_shape.h() << " " + << lower_shape.w() << " " << lower_shape.c() << " " + << "}" << std::endl; + sstream << " - Def Backends : " << def_layouts << std::endl; + sstream << " - Use Backends : " << use_layouts << std::endl; } + dumps.emplace(index.value(), sstream.str()); }); + + for (const auto &e : dumps) + { + if (!e.second.empty()) + { + VERBOSE(Lower) << e.second; + } + } } bool Graph::mergeable(const model::SubgraphIndex &subg_index,