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

Method apply

src/eliminate_allocation.cpp:36–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34inline namespace MIGRAPHX_INLINE_NS {
35
36void eliminate_allocation::apply(module& m) const
37{
38 assert(alignment > 0);
39
40 std::size_t n = 0;
41 std::vector<std::pair<instruction_ref, std::size_t>> allocs;
42 for(auto ins : iterator_for(m))
43 {
44 if(ins->name() != allocation_op)
45 continue;
46 allocs.emplace_back(ins, n);
47 std::size_t size = ins->get_shape().bytes();
48 std::size_t padding = (alignment - (size % alignment)) % alignment;
49 n += size + padding;
50 }
51 if(n > 0)
52 {
53 auto mem = m.add_parameter("memory", shape{shape::int8_type, {n}});
54 for(auto&& pp : allocs)
55 {
56 auto ins = pp.first;
57 auto s = ins->get_shape();
58 auto offset = pp.second;
59 m.replace_instruction(
60 ins, make_op("load", {{"shape", to_value(s)}, {"offset", offset}}), mem);
61 }
62 }
63}
64
65} // namespace MIGRAPHX_INLINE_NS
66} // namespace migraphx

Callers

nothing calls this directly

Calls 9

iterator_forFunction · 0.85
emplace_backMethod · 0.80
add_parameterMethod · 0.80
replace_instructionMethod · 0.80
make_opFunction · 0.70
to_valueFunction · 0.50
nameMethod · 0.45
bytesMethod · 0.45
get_shapeMethod · 0.45

Tested by

no test coverage detected