Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
84707959
Unverified
Commit
84707959
authored
5 years ago
by
Diego Caballero
Committed by
GitHub
5 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3015 from NervanaSystems/dcaballe/mlir_dump
[MLIR] Improve MLIR dump
parents
a1c74973
3358d690
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
16 deletions
+23
-16
compiler.cpp
src/contrib/mlir/compiler.cpp
+19
-8
compiler.hpp
src/contrib/mlir/compiler.hpp
+3
-0
lowerer.cpp
src/contrib/mlir/lowerer.cpp
+1
-8
No files found.
src/contrib/mlir/compiler.cpp
View file @
84707959
...
...
@@ -141,10 +141,9 @@ void MLIRCompiler::build_ng_dialect_module()
{
NGRAPH_FAIL
()
<<
"Invalid module after lowering to NG dialect"
;
}
if
(
std
::
getenv
(
"NGRAPH_MLIR_DUMP_ALL"
)
!=
nullptr
)
{
m_module
->
dump
();
}
dump_mlir_module
(
"nGraph Dialect Dump:"
);
}
// Converts an nGraph Tensor into an MLIR tensor type, including the conversion of the Tensor's
...
...
@@ -215,10 +214,8 @@ void MLIRCompiler::lower_ng_dialect()
{
NGRAPH_FAIL
()
<<
"Incorrect module after dialect lowering"
;
}
if
(
std
::
getenv
(
"NGRAPH_MLIR_DUMP_ALL"
)
!=
nullptr
)
{
m_module
->
dump
();
}
dump_mlir_module
(
"Affine Dialect Dump:"
);
}
// Receives affine dialect as input and applies affine and standard dialect based optimizations.
...
...
@@ -231,6 +228,8 @@ void MLIRCompiler::optimize()
pm
.
addPass
(
mlir
::
createLowerAffinePass
());
auto
rr
=
pm
.
run
(
m_module
.
get
());
NGRAPH_ASSERT
(
succeeded
(
rr
))
<<
"Affine loop lowering failed"
;
dump_mlir_module
(
"Standard Dialect Dump:"
);
}
// MLIR builders
...
...
@@ -346,6 +345,8 @@ void MLIRCompiler::execute()
(
void
)
r
;
NGRAPH_ASSERT
(
succeeded
(
r
))
<<
"second conversion failed"
;
dump_mlir_module
(
"LLVM-IR Dialect Dump:"
);
// Initialize LLVM targets.
llvm
::
InitializeNativeTarget
();
llvm
::
InitializeNativeTargetAsmPrinter
();
...
...
@@ -411,3 +412,13 @@ mlir::StaticFloatMemRef* MLIRCompiler::allocate_memref_descriptor(mlir::Type typ
descriptor
->
data
=
nullptr
;
return
descriptor
;
}
void
MLIRCompiler
::
dump_mlir_module
(
const
std
::
string
msg
)
{
if
(
std
::
getenv
(
"NGRAPH_MLIR_DUMP_ALL"
)
!=
nullptr
)
{
llvm
::
dbgs
()
<<
"*** "
<<
msg
<<
" ***
\n
"
;
m_module
->
dump
();
llvm
::
dbgs
()
<<
"
\n\n
"
;
}
}
This diff is collapsed.
Click to expand it.
src/contrib/mlir/compiler.hpp
View file @
84707959
...
...
@@ -114,6 +114,9 @@ namespace ngraph
/// Helper to allocate a mem ref object. Handles static shapes only for now.
mlir
::
StaticFloatMemRef
*
allocate_memref_descriptor
(
mlir
::
Type
type
);
/// Helper to dump MLIR module into llvm::dbgs prepended by the message \p msg.
void
dump_mlir_module
(
const
std
::
string
msg
);
private
:
// Sub-graph to be compiled and executed with MLIR.
const
ngraph
::
op
::
CompiledKernel
*
m_compiled_kernel
;
...
...
This diff is collapsed.
Click to expand it.
src/contrib/mlir/lowerer.cpp
View file @
84707959
...
...
@@ -112,15 +112,8 @@ namespace
"Error lowering dialect
\n
"
);
signalPassFailure
();
}
if
(
std
::
getenv
(
"NGRAPH_MLIR_DUMP_ALL"
)
!=
nullptr
)
{
getModule
().
dump
();
}
processFakeInstrs
();
if
(
std
::
getenv
(
"NGRAPH_MLIR_DUMP_ALL"
)
!=
nullptr
)
{
getModule
().
dump
();
}
}
void
DialectLoweringPass
::
findOutputValues
()
...
...
This diff is collapsed.
Click to expand it.
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