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
a2b9c6b8
Commit
a2b9c6b8
authored
Jul 26, 2019
by
nmostafa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor optimize() back
parent
6a7e1f24
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
20 deletions
+23
-20
compiler.cpp
src/contrib/mlir/compiler.cpp
+21
-20
compiler.hpp
src/contrib/mlir/compiler.hpp
+2
-0
No files found.
src/contrib/mlir/compiler.cpp
View file @
a2b9c6b8
...
...
@@ -234,31 +234,20 @@ MLIRCompiler::TensorInfo MLIRCompiler::get_tensor_value(descriptor::Tensor* tens
void
MLIRCompiler
::
lower_ng_dialect
()
{
// Lower NG dialect to Affine
{
mlir
::
PassManager
pm
;
pm
.
addPass
(
mlir
::
createDialectLoweringPass
(
this
));
pm
.
addPass
(
mlir
::
createCanonicalizerPass
());
pm
.
run
(
m_module
.
get
());
mlir
::
PassManager
pm
;
pm
.
addPass
(
mlir
::
createDialectLoweringPass
(
this
));
pm
.
addPass
(
mlir
::
createCanonicalizerPass
());
if
(
failed
(
m_module
->
verify
()))
{
NGRAPH_CHECK
(
false
,
"Incorrect module after dialect lowering"
);
}
pm
.
run
(
m_module
.
get
());
dump_mlir_module
(
"Affine Dialect Dump:"
);
if
(
failed
(
m_module
->
verify
()))
{
NGRAPH_CHECK
(
false
,
"Incorrect module after dialect lowering"
);
}
// Lower Affine to Std Dialect
{
mlir
::
PassManager
pm
;
// Lower affine ops
pm
.
addPass
(
mlir
::
createLowerAffinePass
());
auto
rr
=
pm
.
run
(
m_module
.
get
());
NGRAPH_CHECK
(
succeeded
(
rr
),
"Affine loop lowering failed"
);
dump_mlir_module
(
"Affine Dialect Dump:"
);
dump_mlir_module
(
"Standard Dialect Dump:"
);
}
optimize
();
NGRAPH_CHECK
(
m_module
,
"MLIR module is not ready."
);
...
...
@@ -296,6 +285,18 @@ void MLIRCompiler::lower_ng_dialect()
m_engine
=
std
::
move
(
maybeEngine
.
get
());
}
void
MLIRCompiler
::
optimize
()
{
// Lower Affine to Std Dialect
mlir
::
PassManager
pm
;
// Lower affine ops
pm
.
addPass
(
mlir
::
createLowerAffinePass
());
auto
rr
=
pm
.
run
(
m_module
.
get
());
NGRAPH_CHECK
(
succeeded
(
rr
),
"Affine loop lowering failed"
);
dump_mlir_module
(
"Standard Dialect Dump:"
);
}
// MLIR builders
#define TI(x) std::type_index(typeid(x))
...
...
src/contrib/mlir/compiler.hpp
View file @
a2b9c6b8
...
...
@@ -67,6 +67,7 @@ namespace ngraph
/// Compiles a subgraph with MLIR
void
compile
();
/// Executes a pre-compiled subgraph
void
run
(
std
::
vector
<
void
*>&
external_tensors
);
...
...
@@ -88,6 +89,7 @@ namespace ngraph
private
:
void
build_ng_dialect_module
();
void
lower_ng_dialect
();
void
optimize
();
void
bind_arguments
(
std
::
vector
<
void
*>&
external_tensors
);
void
execute
();
void
cleanup
();
...
...
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