From a171956405259c91264df4f0612e9eda11c28056 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, 28 Nov 2019 10:57:31 +0900 Subject: [PATCH] [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 --- runtime/neurun/core/src/graph/Graph.cc | 43 +++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) 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, -- 2.7.4