@@ -97,9 +97,8 @@ struct Node {
97
97
98
98
struct DataFlowEdge {
99
99
Value value;
100
- std::string outPort;
101
100
Node node;
102
- std::string inPort ;
101
+ std::string port ;
103
102
};
104
103
105
104
// / This pass generates a Graphviz dataflow visualization of an MLIR operation.
@@ -153,8 +152,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
153
152
void emitAllEdgeStmts () {
154
153
if (printDataFlowEdges) {
155
154
for (const auto &e : dataFlowEdges) {
156
- emitEdgeStmt (valueToNode[e.value ], e.outPort , e.node , e.inPort ,
157
- kLineStyleDataFlow );
155
+ emitEdgeStmt (valueToNode[e.value ], e.node , e.port , kLineStyleDataFlow );
158
156
}
159
157
}
160
158
@@ -228,8 +226,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
228
226
229
227
// / Append an edge to the list of edges.
230
228
// / Note: Edges are written to the output stream via `emitAllEdgeStmts`.
231
- void emitEdgeStmt (Node n1, std::string outPort, Node n2, std::string inPort,
232
- StringRef style) {
229
+ void emitEdgeStmt (Node n1, Node n2, std::string port, StringRef style) {
233
230
AttributeMap attrs;
234
231
attrs[" style" ] = style.str ();
235
232
// Use `ltail` and `lhead` to draw edges between clusters.
@@ -240,12 +237,14 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
240
237
241
238
edges.push_back (strFromOs ([&](raw_ostream &os) {
242
239
os << " v" << n1.id ;
243
- if (!outPort.empty ())
244
- os << " :" << outPort << " :s" ;
240
+ if (!port.empty ())
241
+ // Attach edge to south compass point of the result
242
+ os << " :" << port << " :s" ;
245
243
os << " -> " ;
246
244
os << " v" << n2.id ;
247
- if (!inPort.empty ())
248
- os << " :" << inPort << " :n" ;
245
+ if (!port.empty ())
246
+ // Attach edge to north compass point of the operand
247
+ os << " :" << port << " :n" ;
249
248
emitAttrList (os, attrs);
250
249
}));
251
250
}
@@ -353,7 +352,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
353
352
for (Operation &op : block) {
354
353
Node nextNode = processOperation (&op);
355
354
if (printControlFlowEdges && prevNode)
356
- emitEdgeStmt (*prevNode, " " , nextNode, " " , kLineStyleControlFlow );
355
+ emitEdgeStmt (*prevNode, nextNode, /* port= */ " " , kLineStyleControlFlow );
357
356
prevNode = nextNode;
358
357
}
359
358
});
@@ -381,8 +380,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
381
380
unsigned numOperands = op->getNumOperands ();
382
381
for (unsigned i = 0 ; i < numOperands; i++) {
383
382
auto operand = op->getOperand (i);
384
- auto inPort = getValuePortName (operand);
385
- dataFlowEdges.push_back ({operand, inPort, node, inPort});
383
+ dataFlowEdges.push_back ({operand, node, getValuePortName (operand)});
386
384
}
387
385
}
388
386
0 commit comments