| 73 | std::string name() const { return "test_loop_op"; } |
| 74 | |
| 75 | migraphx::shape compute_shape(const std::vector<migraphx::shape>& inputs, |
| 76 | std::vector<migraphx::module_ref> mods) const |
| 77 | { |
| 78 | migraphx::check_shapes{inputs, *this}.standard(); |
| 79 | if(mods.size() != 1) |
| 80 | { |
| 81 | MIGRAPHX_THROW("LOOP: operator should have one submodule."); |
| 82 | } |
| 83 | |
| 84 | const auto& mod = mods.front(); |
| 85 | auto mod_out_shapes = mod->get_output_shapes(); |
| 86 | auto dep_param_num = inputs.size() - 2; |
| 87 | |
| 88 | // first item of the mod output shapes is condition used in loop, |
| 89 | // which is not needed to compute output shape |
| 90 | mod_out_shapes.erase(mod_out_shapes.begin()); |
| 91 | std::vector<migraphx::shape> ins_out_shapes(mod_out_shapes.begin(), |
| 92 | mod_out_shapes.begin() + dep_param_num); |
| 93 | mod_out_shapes.erase(mod_out_shapes.begin(), mod_out_shapes.begin() + dep_param_num); |
| 94 | for(const auto& out_s : mod_out_shapes) |
| 95 | { |
| 96 | auto lens = out_s.lens(); |
| 97 | lens.insert(lens.begin(), max_iterations); |
| 98 | ins_out_shapes.push_back({out_s.type(), lens}); |
| 99 | } |
| 100 | |
| 101 | return migraphx::shape(ins_out_shapes); |
| 102 | } |
| 103 | |
| 104 | struct test_loop : public migraphx::op::loop::ref_loop |
| 105 | { |