| 103 | } |
| 104 | |
| 105 | static void create_reduce_modules(module_pass_manager& mpm) |
| 106 | { |
| 107 | std::size_t n = 0; |
| 108 | for(auto ins : iterator_for(mpm.get_module())) |
| 109 | { |
| 110 | if(not ins->get_operator().attributes().get("reduce", false)) |
| 111 | continue; |
| 112 | if(ins->inputs().size() != 1) |
| 113 | continue; |
| 114 | |
| 115 | auto* rm = |
| 116 | mpm.create_module(mpm.get_module().name() + ":" + ins->name() + std::to_string(n++)); |
| 117 | rm->set_bypass(); |
| 118 | |
| 119 | rm->add_return(rm->fuse({ins})); |
| 120 | auto v = ins->get_operator().to_value(); |
| 121 | mpm.get_module().replace_instruction( |
| 122 | ins, make_op("fused_reduce", {{"axes", v["axes"]}}), ins->inputs(), {rm}); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | namespace { |
| 127 |
no test coverage detected