MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / insert_copy

Function insert_copy

src/replace_allocate.cpp:81–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void insert_copy(module& m, const allocation_model& model)
82{
83 auto returns = m.get_returns();
84 std::unordered_set<instruction_ref> returns_set(returns.begin(), returns.end());
85 for(auto ins : returns_set)
86 {
87 if(ins->get_shape().any_of_dynamic())
88 continue;
89 auto aliases = instruction::get_output_alias(ins);
90 if(std::any_of(aliases.begin(), aliases.end(), [&](instruction_ref alias) {
91 return alias->get_shape() == ins->get_shape();
92 }))
93 continue;
94 auto insert_ins = std::next(ins);
95 auto alloc = m.insert_instruction(
96 insert_ins,
97 make_op("allocate", migraphx::value{{"shape", to_value(ins->get_shape())}}));
98 auto copy = m.insert_instruction(insert_ins, make_op(model.copy()), ins, alloc);
99 m.replace_instruction(ins, copy);
100 }
101}
102
103void insert_submod_allocations(instruction_ref ins, module& mod, const allocation_model& model)
104{

Callers 1

applyMethod · 0.85

Calls 11

get_returnsMethod · 0.80
any_of_dynamicMethod · 0.80
insert_instructionMethod · 0.80
replace_instructionMethod · 0.80
make_opFunction · 0.70
any_ofFunction · 0.50
to_valueFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
get_shapeMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected