Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
4ec19433
Commit
4ec19433
authored
Oct 19, 2021
by
Paul
Browse files
Add mlir dump function
parent
71f9ab23
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
src/include/migraphx/mlir.hpp
src/include/migraphx/mlir.hpp
+16
-0
src/mlir.cpp
src/mlir.cpp
+17
-0
No files found.
src/include/migraphx/mlir.hpp
0 → 100644
View file @
4ec19433
#ifndef MIGRAPHX_GUARD_RTGLIB_MLIR_HPP
#define MIGRAPHX_GUARD_RTGLIB_MLIR_HPP
#include <string>
#include <migraphx/config.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
struct
module
;
std
::
string
dump_mlir
(
const
module
&
m
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/mlir.cpp
View file @
4ec19433
#include <migraphx/mlir.hpp>
#include <mlir-c/IR.h>
#include <mlir-c/IR.h>
#include <mlir-c/BuiltinAttributes.h>
#include <mlir-c/BuiltinAttributes.h>
...
@@ -99,6 +100,14 @@ void mlir_print(F f, T x, std::ostream& os)
...
@@ -99,6 +100,14 @@ void mlir_print(F f, T x, std::ostream& os)
mlir_print
(
f
,
x
,
[
&
](
auto
s
)
{
os
<<
s
;
});
mlir_print
(
f
,
x
,
[
&
](
auto
s
)
{
os
<<
s
;
});
}
}
template
<
class
F
,
class
T
>
std
::
string
mlir_print
(
F
f
,
T
x
)
{
std
::
stringstream
ss
;
mlir_print
(
f
,
x
,
[
&
](
auto
s
)
{
ss
<<
s
;
});
return
ss
.
str
();
}
struct
mlir_program
struct
mlir_program
{
{
mlir_program
()
mlir_program
()
...
@@ -411,5 +420,13 @@ struct mlir_program
...
@@ -411,5 +420,13 @@ struct mlir_program
std
::
deque
<
std
::
string
>
strings
{};
std
::
deque
<
std
::
string
>
strings
{};
};
};
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
);
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
}
// namespace migraphx
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment