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
eda52385
Commit
eda52385
authored
May 24, 2019
by
Diego Caballero
Committed by
nmostafa
Jun 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MLIR] Fix redundant MLIR initialization.
MLIR is now initialize once once in CPU backend.
parent
86bc31cc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
14 deletions
+28
-14
CMakeLists.txt
CMakeLists.txt
+1
-0
compiler.cpp
src/contrib/mlir/compiler.cpp
+14
-3
cpu_backend.cpp
src/ngraph/runtime/cpu/cpu_backend.cpp
+13
-0
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+0
-11
No files found.
CMakeLists.txt
View file @
eda52385
...
...
@@ -383,6 +383,7 @@ if (NGRAPH_CPU_ENABLE)
endif
()
if
(
NGRAPH_MLIR_ENABLE
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DNGRAPH_MLIR_ENABLE"
)
set
(
NGRAPH_MLIR_SOURCE_DIR
${
CMAKE_SOURCE_DIR
}
/src/contrib/mlir
)
endif
()
...
...
src/contrib/mlir/compiler.cpp
View file @
eda52385
...
...
@@ -32,6 +32,7 @@
#include <mlir/Target/LLVMIR.h>
#include <mlir/Transforms/DialectConversion.h>
#include <mlir/Transforms/Passes.h>
#include <mutex>
#include "dialect/dialect.hpp"
#include "dialect/type.hpp"
#include "lowerer.hpp"
...
...
@@ -63,9 +64,19 @@ MLIRCompiler::MLIRCompiler(const ngraph::op::CompiledKernel* compiled_kernel,
void
MLIRCompiler
::
init_mlir
()
{
mlir
::
registerDialect
<
mlir
::
NGDialect
>
();
// Register any LLVM command line options
llvm
::
cl
::
ParseEnvironmentOptions
(
"ngraph"
,
"MLIR_LLVM_OPTIONS"
,
""
);
// Mutex to safely initialize MLIR.
static
std
::
mutex
mlir_init_mutex
;
static
bool
initialized
=
false
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
mlir_init_mutex
);
if
(
!
initialized
)
{
mlir
::
registerDialect
<
mlir
::
NGDialect
>
();
// Register any LLVM command line options
llvm
::
cl
::
ParseEnvironmentOptions
(
"ngraph"
,
"MLIR_LLVM_OPTIONS"
,
""
);
initialized
=
true
;
}
}
void
MLIRCompiler
::
compile_and_run
()
...
...
src/ngraph/runtime/cpu/cpu_backend.cpp
View file @
eda52385
...
...
@@ -25,6 +25,11 @@
#include "ngraph/runtime/cpu/cpu_tensor_view.hpp"
#include "ngraph/util.hpp"
#ifdef NGRAPH_MLIR_ENABLE
#include "contrib/mlir/compiler.hpp"
#endif
using
namespace
ngraph
;
using
namespace
std
;
...
...
@@ -90,6 +95,14 @@ shared_ptr<runtime::Executable>
ngraph
::
pass
::
PassConfig
&
pass_config
,
bool
performance_counters_enabled
)
{
#ifdef NGRAPH_MLIR_ENABLE
if
(
std
::
getenv
(
"NGRAPH_MLIR"
)
!=
nullptr
)
{
// Initialize MLIR compiler
ngmlir
::
MLIRCompiler
::
init_mlir
();
}
#endif
shared_ptr
<
runtime
::
Executable
>
rc
;
auto
it
=
m_exec_map
.
find
(
func
);
if
(
it
!=
m_exec_map
.
end
())
...
...
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
eda52385
...
...
@@ -193,9 +193,6 @@
#include "ngraph/runtime/cpu/pass/cpu_workspace_insertion.hpp"
#include "ngraph/runtime/cpu/pass/halide_subgraph_extraction.hpp"
#ifdef NGRAPH_MLIR_ENABLE
#include "contrib/mlir/compiler.hpp"
#endif
using
namespace
std
;
using
namespace
ngraph
;
...
...
@@ -1400,14 +1397,6 @@ void runtime::cpu::CPU_ExternalFunction::build(ngraph::pass::PassConfig& pass_co
// After processing inputs, outputs, constants, and intermediates, set the buffer size.
m_buffer_size
=
buffer_index
;
#ifdef NGRAPH_MLIR_ENABLE
if
(
std
::
getenv
(
"NGRAPH_MLIR"
)
!=
nullptr
)
{
// Initialize MLIR compiler
ngmlir
::
MLIRCompiler
::
init_mlir
();
}
#endif
for
(
shared_ptr
<
Node
>
node
:
m_function
->
get_ordered_ops
())
{
if
(
node
->
is_parameter
()
||
node
->
is_constant
())
...
...
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