222 std::string lookup(
const loco::Node *node)
const final
229 return _content.at(node);
232 std::map<const loco::Node *, std::string> _content;
235 SymbolTableImpl symbols;
237 auto symbol = [&symbols](
const loco::Node *node) {
return symbols.lookup(node); };
239 for (uint32_t n = 0; n < _graph->nodes()->size(); ++n)
241 symbols._content[_graph->nodes()->at(n)] = pp::fmt(
"%", n);
247 std::map<loco::Node *, loco::Node *> parents;
251 parents[node] =
nullptr;
256 for (uint32_t n = 0; n < node->arity(); ++n)
258 if (
auto arg = node->arg(n))
268 while (parents.at(cur) !=
nullptr)
270 cur = parents.at(cur);
276 std::set<loco::Node *> roots;
280 roots.insert(find(node));
283 std::map<loco::Node *, std::set<loco::Node *>> clusters;
286 for (
auto root : roots)
288 clusters[root] = std::set<loco::Node *>{};
293 clusters.at(find(node)).insert(node);
296 std::unique_ptr<locop::NodeSummaryBuilder> node_summary_builder;
301 node_summary_builder = _factory->create(&symbols);
306 node_summary_builder = std::make_unique<GenericNodeSummaryBuilder>(&symbols);
310 for (uint32_t n = 0; n < _graph->inputs()->
size(); ++n)
312 auto input = _graph->inputs()->at(n);
314 std::string name = input->name();
316 std::string shape =
"?";
317 if (input->shape() !=
nullptr)
319 shape = pp::fmt(formatted_tensor_shape(input->shape()));
323 os << pp::fmt(
"In #", n,
" { name: ", name,
", shape: ", shape,
" }") << std::endl;
327 for (uint32_t n = 0; n < _graph->outputs()->
size(); ++n)
329 auto output = _graph->outputs()->at(n);
331 std::string name = output->name();
333 std::string shape =
"?";
334 if (output->shape() !=
nullptr)
336 shape = pp::fmt(formatted_tensor_shape(output->shape()));
340 os << pp::fmt(
"Out #", n,
" { name: ", name,
", shape: ", shape,
" }") << std::endl;
343 if (_graph->inputs()->size() + _graph->outputs()->size() != 0)
348 for (
auto it = clusters.begin(); it != clusters.end(); ++it)
350 std::vector<loco::Node *> cluster_outputs;
352 for (
auto node : it->second)
357 cluster_outputs.emplace_back(node);
366 if (!node_summary_builder->build(node, node_summary))
368 throw std::runtime_error{
"Fail to build a node summary"};
371 for (uint32_t n = 0; n < node_summary.
comments().
count(); ++n)
373 os <<
"; " << node_summary.
comments().
at(n) << std::endl;
381 os <<
" : " << str(node_shape.
domain());
383 os << str(node_shape);
390 os <<
" = " << node_summary << std::endl;