"vscode:/vscode.git/clone" did not exist on "39bbf87c92e43826ba9db6e42a4f8d7ca1c62daf"
preallocate_param.cpp 844 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
{
    for(auto ins : iterator_for(p))
    {
        if(ins->name() != "@param")
            continue;
Shucai Xiao's avatar
Shucai Xiao committed
19
        if(param != any_cast<builtin::param>(ins->get_operator()).parameter)
20
            continue;
Shucai Xiao's avatar
Shucai Xiao committed
21
22
        std::string id = p.name() + ":" + param;
        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