preallocate_param.cpp 816 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
#include <migraphx/gpu/preallocate_param.hpp>
#include <migraphx/gpu/hip.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/stringutils.hpp>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {

13
void preallocate_param::apply(module& p) const
14
15
16
17
18
19
20
21
{
    for(auto ins : iterator_for(p))
    {
        if(ins->name() != "@param")
            continue;
        std::string id = any_cast<builtin::param>(ins->get_operator()).parameter;
        if(id != param)
            continue;
22
        auto r = p.insert_instruction(ins, hip_allocate_memory{ins->get_shape(), id});
23
24
25
26
27
28
29
        p.replace_instruction(ins, r);
    }
}

} // namespace gpu
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx