mlir.cpp 1.03 KB
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
6
7
8
9
10
11
12
#include <migraphx/gpu/compiler.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/gpu/context.hpp>

#include <migraphx/gpu/mlir.hpp>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {

struct mlir_compiler : compiler<mlir_compiler>
{
Paul's avatar
Format  
Paul committed
13
    std::vector<std::string> names() const { return {"gpu::mlir_conv"}; }
Paul's avatar
Paul committed
14

Paul's avatar
Format  
Paul committed
15
    operation compile_op(context&, const std::vector<shape>&, const value&) const { return {}; }
Paul's avatar
Paul committed
16
17
18
19
20
21
22
23
24
25

    compiler_replace compile(context& ctx, instruction_ref ins, const operation&) const
    {
        auto* smod = ins->module_inputs().front();
        assert(smod->get_parameter_names().size() == ins->inputs().size() - 1);
        return insert(compile_mlir(ctx, *smod));
    }

    compiler_replace insert(code_object_op co) const
    {
Paul's avatar
Foramt  
Paul committed
26
        return [co = std::move(co)](module& m, instruction_ref ins) {
Paul's avatar
Paul committed
27
            auto mlir = insert_mlir(m, ins, co, ins->inputs());
Paul's avatar
Format  
Paul committed
28
            m.replace_instruction(ins, mlir);
Paul's avatar
Paul committed
29
30
31
32
33
34
35
        };
    }
};

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