| 91 | } |
| 92 | |
| 93 | void transform_convolutions(module& m, const layout_convolution& lc) |
| 94 | { |
| 95 | for(auto ins : iterator_for(m)) |
| 96 | { |
| 97 | if(not contains({"convolution", "quant_convolution"}, ins->name())) |
| 98 | continue; |
| 99 | if(ins->get_shape().dynamic()) |
| 100 | continue; |
| 101 | if(ins->get_shape().lens().size() != 4) |
| 102 | continue; |
| 103 | auto v = ins->get_operator().to_value(); |
| 104 | bool is_group_conv = v.at("group").to<int>() > 1; |
| 105 | auto args = ins->inputs(); |
| 106 | auto perm = is_group_conv ? get_default_permutation(ins) : get_permutation(ins, lc); |
| 107 | std::transform(args.begin(), args.end(), args.begin(), [&](const auto& i) { |
| 108 | return m.insert_instruction(ins, make_op("layout", {{"permutation", perm}}), i); |
| 109 | }); |
| 110 | auto conv = m.insert_instruction(ins, ins->get_operator(), args); |
| 111 | auto c = m.insert_instruction(ins, make_op("contiguous"), conv); |
| 112 | m.replace_instruction(ins, c); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | void remove_layout(module& m) |
| 117 | { |
no test coverage detected