caffe2/core/nomnigraph/tests/subgraph_matcher_test.cc
// Realistic data flow test graph.
/*


                          +---------------+
                          |               |
                          |  +---------+  |  +---------+
    +---------------------+  | input_A |  |  | input_B |
    |                        +---------+  |  +---------+
    |                          |          |    |
    |                          |          |    |
    |                          v          v    v
  +---------++---------+     +-------------------------+     +--------+
  | input_C || input_D | --> |           opC           | --> | dataC2 |
  +---------++---------+     +-------------------------+     +--------+
                               |
                               |
                               v
                             +---------+
                             |  dataC  | -+
                             +---------+  |
                               |          |
                               |          |
                               v          |
                             +---------+  |
                             |   opB   | <+
                             +---------+
                               |
                               |
                               v
                             +---------+
                             |  dataB  |
                             +---------+
                               |
                               |
                               v
                             +---------+
                             |   opF   |
                             +---------+
                               |
                               |
                               v
                             +---------+
                             |  dataF  |
                             +---------+
                               |
                               |
                               v
             +---------+     +---------+
             |  dataI  | --> |   opG   |
             +---------+     +---------+
                               |
                               |
                               v
                             +---------+
                             | dataOut |
                             +---------+
  */
Realistic data flow test graph.
Realistic data flow test graph .
DataFlowTestGraph() {
    opC = graph.createNode("opC");
    for (int i = 0; i < numInputs; i++) {
      auto dataInput = graph.createNode("input");
      graph.createEdge(dataInput, opC);
    }
    auto dataC = graph.createNode("dataC");
    auto dataC2 = graph.createNode("dataC2");
    graph.createEdge(opC, dataC);
    graph.createEdge(opC, dataC2);
    opB = graph.createNode("opB");
    graph.createEdge(dataC, opB);
    graph.createEdge(dataC, opB);
    auto dataB = graph.createNode("dataB");
    graph.createEdge(opB, dataB);
    opF = graph.createNode("opF");
    graph.createEdge(dataB, opF);
    auto dataF = graph.createNode("dataF");
    graph.createEdge(opF, dataF);
    auto dataI = graph.createNode("dataI");
    opG = graph.createNode("opG");
    graph.createEdge(dataF, opG);
    graph.createEdge(dataI, opG);
    dataOut = graph.createNode("dataOut");
    graph.createEdge(opG, dataOut);
  }
DataFlowTestGraph ( ) { opC = graph . createNode ( " " ) ; for ( int i = 0 ; i < numInputs ; i ++ ) { auto dataInput = graph . createNode ( " " ) ; graph . createEdge ( dataInput , opC ) ; } auto dataC = graph . createNode ( " " ) ; auto dataC2 = graph . createNode ( " " ) ; graph . createEdge ( opC , dataC ) ; graph . createEdge ( opC , dataC2 ) ; opB = graph . createNode ( " " ) ; graph . createEdge ( dataC , opB ) ; graph . createEdge ( dataC , opB ) ; auto dataB = graph . createNode ( " " ) ; graph . createEdge ( opB , dataB ) ; opF = graph . createNode ( " " ) ; graph . createEdge ( dataB , opF ) ; auto dataF = graph . createNode ( " " ) ; graph . createEdge ( opF , dataF ) ; auto dataI = graph . createNode ( " " ) ; opG = graph . createNode ( " " ) ; graph . createEdge ( dataF , opG ) ; graph . createEdge ( dataI , opG ) ; dataOut = graph . createNode ( " " ) ; graph . createEdge ( opG , dataOut ) ; }
Realistic data flow test graph.
Realistic data flow test graph .
// There are 2 edges // Use nom::converters::convertToDotString(&graph, TestGraphNodePrinter) // to visualize the graph.