@@ -97,9 +97,8 @@ struct Node {
9797
9898struct DataFlowEdge {
9999 Value value;
100- std::string outPort;
101100 Node node;
102- std::string inPort ;
101+ std::string port ;
103102};
104103
105104// / This pass generates a Graphviz dataflow visualization of an MLIR operation.
@@ -153,8 +152,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
153152 void emitAllEdgeStmts () {
154153 if (printDataFlowEdges) {
155154 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 );
158156 }
159157 }
160158
@@ -228,8 +226,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
228226
229227 // / Append an edge to the list of edges.
230228 // / 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) {
233230 AttributeMap attrs;
234231 attrs[" style" ] = style.str ();
235232 // Use `ltail` and `lhead` to draw edges between clusters.
@@ -240,12 +237,14 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
240237
241238 edges.push_back (strFromOs ([&](raw_ostream &os) {
242239 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" ;
245243 os << " -> " ;
246244 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" ;
249248 emitAttrList (os, attrs);
250249 }));
251250 }
@@ -353,7 +352,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
353352 for (Operation &op : block) {
354353 Node nextNode = processOperation (&op);
355354 if (printControlFlowEdges && prevNode)
356- emitEdgeStmt (*prevNode, " " , nextNode, " " , kLineStyleControlFlow );
355+ emitEdgeStmt (*prevNode, nextNode, /* port= */ " " , kLineStyleControlFlow );
357356 prevNode = nextNode;
358357 }
359358 });
@@ -381,8 +380,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
381380 unsigned numOperands = op->getNumOperands ();
382381 for (unsigned i = 0 ; i < numOperands; i++) {
383382 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)});
386384 }
387385 }
388386
0 commit comments