*/
#include <fstream>
+#include <unordered_map>
#include "DotDumper.h"
#include "DotBuilder.h"
auto &operations = _graph.operations();
auto &operands = _graph.operands();
- operations.iterate([&](const model::OperationIndex &index, const model::Operation &node) {
- neurun::dumper::dot::OperationNode node_info(index, node);
+ std::unordered_map<model::OperationIndex, std::unique_ptr<OperationNode>> operation_nodes;
+ std::unordered_map<model::OperandIndex, std::unique_ptr<OperandNode>> operand_nodes;
- for (auto output : node.getOutputs())
+ operations.iterate([&](const model::OperationIndex &index, const model::Operation &op) {
+ auto node = nnfw::cpp14::make_unique<OperationNode>(index, op);
+
+ for (auto output : op.getOutputs())
{
using neurun::dumper::dot::OperandNode;
auto child = std::make_shared<OperandNode>(output, OperandNode::Type::MODEL_OUTPUT,
_graph.getLowerInfo(output));
- node_info.addEdge(child);
+ node->addEdge(child);
}
- dot_builder.update(node_info);
+ operation_nodes.emplace(index, std::move(node));
});
util::Set<model::OperandIndex> shown_operand_set;
}();
auto lower_info = _graph.getLowerInfo(index);
- neurun::dumper::dot::OperandNode operand_info(index, type, lower_info);
+ auto node = nnfw::cpp14::make_unique<OperandNode>(index, type, lower_info);
for (auto operation_index : object.getUses().list())
{
- auto &node = operations.at(operation_index);
- auto child = std::make_shared<neurun::dumper::dot::OperationNode>(operation_index, node);
- operand_info.addEdge(child);
+ auto &operation = operations.at(operation_index);
+ auto child = std::make_shared<OperationNode>(operation_index, operation);
+ node->addEdge(child);
}
- dot_builder.update(operand_info);
+ operand_nodes.emplace(index, std::move(node));
}
});
subg_ctx->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())
+ {
+ auto found = operation_nodes.find(op.index);
+ if (found != operation_nodes.end())
+ {
+ found->second->setAttribute("fillcolor", "lightgrey");
+ }
+ }
});
}
+ for (const auto &e : operation_nodes)
+ dot_builder.update(*e.second);
+ for (const auto &e : operand_nodes)
+ dot_builder.update(*e.second);
+
// Dump to file
{
std::string file_name;