| 66 | } |
| 67 | |
| 68 | void preserve_output_layout(module& m) |
| 69 | { |
| 70 | auto last = std::prev(m.end()); |
| 71 | if(last->name() == "@return") |
| 72 | { |
| 73 | std::vector<instruction_ref> outputs; |
| 74 | std::transform(last->inputs().begin(), |
| 75 | last->inputs().end(), |
| 76 | std::back_inserter(outputs), |
| 77 | [&](instruction_ref ins) { |
| 78 | if(skip_layout(ins->get_shape())) |
| 79 | return ins; |
| 80 | auto permutation = find_permutation(ins->get_shape()); |
| 81 | return m.insert_instruction( |
| 82 | last, make_op("layout", {{"permutation", permutation}}), ins); |
| 83 | }); |
| 84 | m.replace_return(outputs); |
| 85 | } |
| 86 | else if(not skip_layout(last->get_shape())) |
| 87 | { |
| 88 | auto permutation = find_permutation(last->get_shape()); |
| 89 | m.add_instruction(make_op("layout", {{"permutation", permutation}}), last); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | void transform_convolutions(module& m, const layout_convolution& lc) |
| 94 | { |
no test coverage detected