Check the module is topologically sorted TODO: Use test::make_predicate
| 38 | // Check the module is topologically sorted |
| 39 | // TODO: Use test::make_predicate |
| 40 | static bool is_sorted(migraphx::module& m) |
| 41 | { |
| 42 | std::unordered_set<migraphx::instruction_ref> visited; |
| 43 | for(auto ins : migraphx::iterator_for(m)) |
| 44 | { |
| 45 | visited.insert(ins); |
| 46 | if(std::any_of(ins->inputs().begin(), ins->inputs().end(), [&](auto i) { |
| 47 | return not visited.count(i); |
| 48 | })) |
| 49 | { |
| 50 | return false; // Found an input that has not been visited yet |
| 51 | } |
| 52 | } |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | static void shuffle_module(migraphx::module& m) |
| 57 | { |