-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into gqa-jit
- Loading branch information
Showing
13 changed files
with
364 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,4 @@ pybind/pybind11@3e9dfa2866941655c56877882565e7577de6fc7b --build | |
msgpack/[email protected] -DMSGPACK_BUILD_TESTS=Off | ||
sqlite3@3.43.2 -DCMAKE_POSITION_INDEPENDENT_CODE=On | ||
ROCm/composable_kernel@57cdd70b7cb14e5e3b60cd9a5f96ba8dc343763e -DCK_BUILD_JIT_LIB=On -DCMAKE_POSITION_INDEPENDENT_CODE=On | ||
ROCm/rocMLIR@424059e63114ba32827a9f022233fc15ed8e3378 -DBUILD_FAT_LIBROCKCOMPILER=On | ||
ROCm/rocMLIR@82378ac44b8627ecbaf9078353fb53588090fe28 -DBUILD_FAT_LIBROCKCOMPILER=On |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ add_executable(driver | |
main.cpp | ||
verify.cpp | ||
passes.cpp | ||
mlir.cpp | ||
models.cpp | ||
perf.cpp | ||
marker_roctx.cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "mlir.hpp" | ||
#include <migraphx/module.hpp> | ||
#include <migraphx/make_op.hpp> | ||
#include <migraphx/iterator_for.hpp> | ||
#include <migraphx/ranges.hpp> | ||
#include <migraphx/instruction.hpp> | ||
#include <migraphx/param_utils.hpp> | ||
#include <migraphx/dead_code_elimination.hpp> | ||
#include <migraphx/pass_manager.hpp> | ||
#include <unordered_map> | ||
|
||
namespace migraphx { | ||
namespace driver { | ||
inline namespace MIGRAPHX_INLINE_NS { | ||
|
||
void offload_to_mlir(program& p) | ||
{ | ||
auto* mm = p.get_main_module(); | ||
auto* mlirm = p.create_module("mlir"); | ||
mlirm->set_bypass(); | ||
std::vector<instruction_ref> inputs; | ||
copy_if(iterator_for(*mm), std::back_inserter(inputs), [&](instruction_ref ins) { | ||
if(ins->name() == "@param") | ||
return true; | ||
if(ins->name() == "@literal") | ||
return ins->get_shape().elements() != 1; | ||
return false; | ||
}); | ||
|
||
std::unordered_map<instruction_ref, instruction_ref> map_ins; | ||
std::size_t n = 0; | ||
for(auto ins : inputs) | ||
{ | ||
map_ins[ins] = mlirm->add_parameter(param_name(n++), ins->get_shape().as_standard()); | ||
} | ||
|
||
auto mlir_last = mlirm->add_instructions(mm, &map_ins); | ||
mlirm->add_return(mlir_last); | ||
|
||
auto last = std::prev(mm->end()); | ||
auto mlir_op = mm->insert_instruction(last, make_op("gpu::mlir_op"), inputs, {mlirm}); | ||
if(mlir_last.size() > 1) | ||
{ | ||
std::vector<instruction_ref> outputs; | ||
transform(range(mlir_last.size()), std::back_inserter(outputs), [&](auto i) { | ||
return mm->insert_instruction(last, make_op("get_tuple_elem", {{"index", i}}), mlir_op); | ||
}); | ||
mm->replace_return(outputs); | ||
} | ||
else | ||
{ | ||
mm->replace_return({mlir_op}); | ||
} | ||
run_passes(*mm, {dead_code_elimination{}}); | ||
} | ||
|
||
} // namespace MIGRAPHX_INLINE_NS | ||
} // namespace driver | ||
} // namespace migraphx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef MIGRAPHX_GUARD_DRIVER_MLIR_HPP | ||
#define MIGRAPHX_GUARD_DRIVER_MLIR_HPP | ||
|
||
#include <migraphx/config.hpp> | ||
#include <migraphx/program.hpp> | ||
|
||
namespace migraphx { | ||
namespace driver { | ||
inline namespace MIGRAPHX_INLINE_NS { | ||
|
||
void offload_to_mlir(program& p); | ||
|
||
} // namespace MIGRAPHX_INLINE_NS | ||
} // namespace driver | ||
} // namespace migraphx | ||
#endif // MIGRAPHX_GUARD_DRIVER_MLIR_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.