-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show mlir program when tracing benchmarking #2741
Changes from 5 commits
3b7de87
2ef5a25
3cd5bcc
9af7f32
7a53ebf
7c3a2ab
cbf7536
99404b0
e1e1d34
c9a7368
a851003
efbcb01
30e1e25
5572ba7
26f6742
7263ac2
cec1a18
c5a4040
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -934,14 +934,6 @@ struct mlir_program | |
std::string sym_name; | ||
}; | ||
|
||
std::string dump_mlir(const module& m) | ||
{ | ||
mlir_program mp; | ||
mp.parse(m); | ||
auto mod_op = mlirModuleGetOperation(mp.mmodule.get()); | ||
return mlir_print(&mlirOperationPrint, mod_op); | ||
} | ||
|
||
void adjust_param_shapes(module& m, const std::vector<shape>& inputs) | ||
{ | ||
auto names = m.get_parameter_names(); | ||
|
@@ -960,6 +952,24 @@ void adjust_param_shapes(module& m, const std::vector<shape>& inputs) | |
} | ||
} | ||
|
||
std::string dump_mlir(const module& m, const std::vector<shape>& inputs) | ||
{ | ||
module mm; | ||
const_module_ref mr = &m; | ||
if(not inputs.empty()) | ||
{ | ||
mm = m; | ||
mr = &mm; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does it require const_ref ? Shouldn't just copied module There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I only want to copy the module if there is no input shapes because we wont be adjusting the parameters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Module with empty input shape is unlikely case it would have been const-folded. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is better to assume inputs are not empty. it would be simpler There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is two overloads to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes but those input shapes parameter would be input arguments to the precompile_op instruction. If they are empty that means MLIR module also doesn't take any inputs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the inputs are empty it means skip doing param adjustments. |
||
adjust_param_shapes(mm, inputs); | ||
} | ||
mlir_program mp; | ||
mp.parse(*mr); | ||
auto mod_op = mlirModuleGetOperation(mp.mmodule.get()); | ||
return mlir_print(&mlirOperationPrint, mod_op); | ||
} | ||
|
||
std::string dump_mlir(const module& m) { return dump_mlir(m, {}); } | ||
|
||
code_object_op compile_mlir(const context& migraphx_ctx, | ||
module m, | ||
const std::vector<instruction_ref>& inputs, | ||
|
@@ -1030,13 +1040,20 @@ tuning_config get_tuning_config_mlir(const context& migraphx_ctx, | |
|
||
#else | ||
|
||
std::string dump_mlir(const module&) { return {}; } | ||
|
||
template <class T> | ||
void use(T&) | ||
{ | ||
} | ||
|
||
std::string dump_mlir(const module&) { return {}; } | ||
|
||
std::string dump_mlir(const module& m, const std::vector<shape>& inputs) | ||
{ | ||
use(m); | ||
use(inputs); | ||
return {}; | ||
} | ||
|
||
// Disabling clang-tidy warning on non-real useage. | ||
// NOLINTBEGIN(performance-unnecessary-value-param) | ||
code_object_op | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add this option to documents