| 272 | } |
| 273 | |
| 274 | static bool find_pointwise_modules(module_pass_manager& mpm, bool multi_out) |
| 275 | { |
| 276 | bool changed = false; |
| 277 | auto last = std::prev(mpm.get_module().end()); |
| 278 | for(auto ins : iterator_for(mpm.get_module())) |
| 279 | { |
| 280 | if(ins != last and is_dead(ins)) |
| 281 | continue; |
| 282 | auto pw_outs = find_output_pointwise(mpm.get_module(), ins, multi_out); |
| 283 | |
| 284 | if(pw_outs.size() > 1) |
| 285 | { |
| 286 | (void)std::accumulate( |
| 287 | pw_outs.begin() + 1, pw_outs.end(), pw_outs.front(), [&](auto input, auto output) { |
| 288 | return merge_instruction(mpm, input, output); |
| 289 | }); |
| 290 | changed = true; |
| 291 | } |
| 292 | else if(ins->name() == "pointwise") |
| 293 | { |
| 294 | auto it = find_input_pointwise(mpm.get_module(), ins, multi_out); |
| 295 | if(it == ins->inputs().end()) |
| 296 | continue; |
| 297 | auto input = *it; |
| 298 | if(is_dead(input)) |
| 299 | continue; |
| 300 | merge_instruction(mpm, input, ins); |
| 301 | |
| 302 | changed = true; |
| 303 | } |
| 304 | } |
| 305 | return changed; |
| 306 | } |
| 307 | |
| 308 | namespace { |
| 309 | struct pointwise_reshape : rewrite_reshapes_base |
no test coverage detected