9 std::string to_string(
T value) {
10 std::ostringstream os;
19 auto entry = graph.
createNode(std::string(
"entry"));
27 auto exit = graph.
createNode(std::string(
"exit"));
42 auto entry = graph.
createNode(std::string(
"entry"));
50 auto exit = graph.
createNode(std::string(
"exit"));
64 std::map<std::string, std::string> BBPrinter(
typename nom::repr::NNCFGraph::NodeRef node) {
65 std::map<std::string, std::string> labelMap;
66 auto& bb = node->data();
67 labelMap[
"label"] = to_string((
unsigned long long)node) +
"\\n";
68 for (
const auto& instr : bb.getInstructions()) {
69 assert(isa<nom::repr::NeuralNetOperator>(instr->data()) &&
70 "Invalid instruction.");
72 bool hasOutput =
false;
73 for (
const auto &outEdge : instr->getOutEdges()) {
76 labelMap[
"label"] +=
" " + output->getName();
80 labelMap[
"label"] +=
" = ";
82 labelMap[
"label"] += op->getName();
83 for (
const auto &inEdge : instr->getInEdges()) {
86 labelMap[
"label"] +=
" " + arg->getName();
88 labelMap[
"label"] +=
"\\l";
90 labelMap[
"shape"] =
"box";
94 std::map<std::string, std::string> cfgEdgePrinter(
typename nom::repr::NNCFGraph::EdgeRef edge) {
95 std::map<std::string, std::string> labelMap;
96 if (edge->data() == -1) {
97 labelMap[
"label"] =
"F";
98 }
else if (edge->data() == 1) {
99 labelMap[
"label"] =
"T";
105 std::map<std::string, std::string> labelMap;
106 assert(node->data() &&
"Node doesn't have data, can't render it");
107 if (isa<nom::repr::NeuralNetOperator>(node->data())) {
110 op->getName() +
" (" + to_string((
unsigned long long)node) +
")";
111 labelMap[
"shape"] =
"box";
112 }
else if (isa<nom::repr::Data>(node->data())) {
114 labelMap[
"label"] = tensor->getName();
115 labelMap[
"label"] +=
"_" + to_string(tensor->getVersion()) +
" " + to_string((
unsigned long long)node);
124 std::map<std::string, std::string> TestNodePrinter(
126 std::map<std::string, std::string> labelMap;
127 labelMap[
"label"] =
"Node";
NodeRef createNode(T &&data)
Creates a node and retains ownership of it.
A simple graph implementation.
EdgeRef createEdge(NodeRef tail, NodeRef head, U...data)
Creates a directed edge and retains ownership of it.