@@ -160,77 +160,6 @@ TEST(DataFlowGraph, Build_IR_Graph) {
160
160
ASSERT_EQ (graph.nodes .size (), ir_graph.Nodes ().size ());
161
161
}
162
162
163
- // FlexibleDFS
164
- /*
165
- * Graph topology
166
- * inputs: 0
167
- * 0 -> 1
168
- * 1 -> 2
169
- * 1 -> 3
170
- * 3 -> 4
171
- * 4 -> 5
172
- * 5 -> 2
173
- */
174
- TEST (DataFlowGraph, flexibledfs) {
175
- DataFlowGraph graph;
176
-
177
- for (int i = 0 ; i < 6 ; i++) {
178
- auto * node = graph.nodes .Create (Node::Type::kValue );
179
- node->SetName (" node-" + std::to_string (i));
180
- }
181
-
182
- auto add_link = [&](int i, int j) {
183
- Node* source = graph.nodes .GetMutable (i);
184
- Node* target = graph.nodes .GetMutable (j);
185
- target->inlinks .push_back (source);
186
- source->outlinks .push_back (target);
187
- };
188
-
189
- add_link (0 , 1 );
190
- add_link (1 , 2 );
191
- add_link (1 , 3 );
192
- add_link (3 , 4 );
193
- add_link (4 , 5 );
194
- add_link (5 , 2 );
195
- graph.Build ();
196
-
197
- std::vector<const Node*> order;
198
- FlexibleDFS (graph.inputs (), false , nullptr , [&order](const Node* n) {
199
- order.push_back (n);
200
- return true ;
201
- });
202
-
203
- ASSERT_EQ (order.size (), 6UL );
204
-
205
- order.clear ();
206
- // reverse dfs
207
- FlexibleDFS (graph.outputs (), true , nullptr , [&order](const Node* n) {
208
- order.push_back (n);
209
- return true ;
210
- });
211
-
212
- ASSERT_EQ (order.size (), 6UL );
213
-
214
- // If we delete
215
- Node* last_node = graph.nodes .GetMutable (2 );
216
- Node* direct_node = graph.nodes .GetMutable (1 );
217
- std::vector<Node*> source_nodes;
218
- for (Node* node : last_node->inlinks ) {
219
- if (node != direct_node) source_nodes.push_back (node);
220
- }
221
-
222
- bool has_cycle = false ;
223
- FlexibleDFS (source_nodes, true , nullptr ,
224
- [&has_cycle, direct_node](const Node* n) {
225
- if (n == direct_node) {
226
- has_cycle = true ;
227
- return false ;
228
- }
229
- return true ;
230
- });
231
- ASSERT_TRUE (has_cycle);
232
- }
233
-
234
163
} // namespace analysis
235
164
} // namespace inference
236
165
} // namespace paddle
0 commit comments