| 43 | MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_MLIR_DUMP); |
| 44 | |
| 45 | static module create_pointwise_module(module_ref in_mod) |
| 46 | { |
| 47 | module pw_mod; |
| 48 | std::unordered_map<instruction_ref, instruction_ref> map_ins; |
| 49 | for(auto param : in_mod->get_parameters()) |
| 50 | { |
| 51 | map_ins[param] = |
| 52 | pw_mod.add_parameter(any_cast<builtin::param>(param->get_operator()).parameter, |
| 53 | shape{param->get_shape().type()}); |
| 54 | } |
| 55 | auto return_args = |
| 56 | pw_mod.add_instructions(in_mod, |
| 57 | &map_ins, |
| 58 | [](module& m, |
| 59 | instruction_ref ins, |
| 60 | const operation& op, |
| 61 | const std::vector<instruction_ref>& inputs, |
| 62 | const std::vector<module_ref>& mod_args) -> instruction_ref { |
| 63 | auto out_aliases = op.output_alias(to_shapes(inputs)); |
| 64 | if(out_aliases.size() == 1) |
| 65 | return inputs.at(out_aliases[0]); |
| 66 | else |
| 67 | return m.insert_instruction(ins, op, inputs, mod_args); |
| 68 | }); |
| 69 | pw_mod.add_return(return_args); |
| 70 | return pw_mod; |
| 71 | } |
| 72 | |
| 73 | static code_object_op |
| 74 | compile_pointwise_module(context& ctx, const std::vector<shape>& inputs, module_ref mod) |
no test coverage detected