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
cbdb405e
Commit
cbdb405e
authored
Jun 10, 2019
by
nmostafa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PR fixes
parent
9f0e1f60
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
58 additions
and
44 deletions
+58
-44
CMakeLists.txt
CMakeLists.txt
+3
-3
external_mlir.cmake
cmake/external_mlir.cmake
+14
-17
mlir_fetch.cmake.in
cmake/mlir_fetch.cmake.in
+3
-3
CMakeLists.txt
src/contrib/mlir/CMakeLists.txt
+1
-4
compiler.cpp
src/contrib/mlir/compiler.cpp
+12
-1
compiler.hpp
src/contrib/mlir/compiler.hpp
+1
-1
dialect.cpp
src/contrib/mlir/dialect/dialect.cpp
+1
-1
ops.cpp
src/contrib/mlir/dialect/ops.cpp
+1
-1
ops.hpp
src/contrib/mlir/dialect/ops.hpp
+1
-1
ops.td
src/contrib/mlir/dialect/ops.td
+1
-1
type.cpp
src/contrib/mlir/dialect/type.cpp
+1
-1
type.hpp
src/contrib/mlir/dialect/type.hpp
+1
-1
lowerer.cpp
src/contrib/mlir/lowerer.cpp
+1
-1
lowerer.hpp
src/contrib/mlir/lowerer.hpp
+1
-1
memory_manager.cpp
src/contrib/mlir/memory_manager.cpp
+1
-1
memory_manager.hpp
src/contrib/mlir/memory_manager.hpp
+1
-1
op_lowerers.inc
src/contrib/mlir/op_lowerers.inc
+1
-1
mlir_subgraph_extraction.cpp
src/contrib/mlir/pass/mlir_subgraph_extraction.cpp
+11
-1
mlir_subgraph_extraction.hpp
src/contrib/mlir/pass/mlir_subgraph_extraction.hpp
+1
-2
mlir_cpu_compiled_kernel.cpp
src/ngraph/runtime/cpu/builder/mlir_cpu_compiled_kernel.cpp
+1
-1
No files found.
CMakeLists.txt
View file @
cbdb405e
...
...
@@ -190,10 +190,10 @@ if (NGRAPH_CPU_ENABLE
set
(
NGRAPH_INTEL_CPU_ONLY_ENABLE ON
)
endif
()
if
(
NGRAPH_MLIR_ENABLE
)
if
(
NGRAPH_MLIR_ENABLE
AND
(
NOT NGRAPH_DEX_ONLY
)
)
#disable code-gen due to sym collision with LLVM
message
(
STATUS
"Forcing NGRAPH_DEX_ONLY to ON"
)
set
(
NGRAPH_DEX_ONLY ON
)
message
(
FATAL_ERROR
"Cannot build with both MLIR and code-gen ON.
\n
"
"Use -DNGRAPH_DEX_ONLY=ON and try again.
\n
"
)
endif
()
if
(
NGRAPH_DISTRIBUTED_ENABLE
)
...
...
cmake/external_mlir.cmake
View file @
cbdb405e
# ******************************************************************************
# Copyright 2019 Intel Corporation
# Copyright 201
7-201
9 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -29,26 +29,23 @@ set(MLIR_BUILD_DIR ${MLIR_LLVM_ROOT}/build)
# MLIR has to be pre-built before ngraph build starts
# this will clone and build MLIR during cmake config instead
find_program
(
NINJA ninja
)
if
(
NINJA
)
configure_file
(
${
CMAKE_SOURCE_DIR
}
/cmake/mlir_fetch.cmake.in
${
MLIR_PROJECT_ROOT
}
/CMakeLists.txt
)
execute_process
(
COMMAND
"
${
CMAKE_COMMAND
}
"
-G
"
${
CMAKE_GENERATOR
}
"
.
configure_file
(
${
CMAKE_SOURCE_DIR
}
/cmake/mlir_fetch.cmake.in
${
MLIR_PROJECT_ROOT
}
/CMakeLists.txt
)
execute_process
(
COMMAND
"
${
CMAKE_COMMAND
}
"
-G
"
${
CMAKE_GENERATOR
}
"
.
WORKING_DIRECTORY
"
${
MLIR_PROJECT_ROOT
}
"
)
# clone and build llvm
execute_process
(
COMMAND
"
${
CMAKE_COMMAND
}
"
--build . --target ext_mlir_llvm
# clone and build llvm
execute_process
(
COMMAND
"
${
CMAKE_COMMAND
}
"
--build . --target ext_mlir_llvm
WORKING_DIRECTORY
"
${
MLIR_PROJECT_ROOT
}
"
)
# clone and build mlir
execute_process
(
COMMAND
"
${
CMAKE_COMMAND
}
"
--build . --target ext_mlir
# clone and build mlir
execute_process
(
COMMAND
"
${
CMAKE_COMMAND
}
"
--build . --target ext_mlir
WORKING_DIRECTORY
"
${
MLIR_PROJECT_ROOT
}
"
)
# point find_package to the pre-built libs
set
(
LLVM_DIR
${
MLIR_LLVM_ROOT
}
/build/lib/cmake/llvm
)
# point find_package to the pre-built libs
set
(
LLVM_DIR
${
MLIR_LLVM_ROOT
}
/build/lib/cmake/llvm
)
set
(
MLIR_SRC_INCLUDE_PATH
${
MLIR_SOURCE_DIR
}
/include
)
set
(
MLIR_BIN_INCLUDE_PATH
${
MLIR_BUILD_DIR
}
/projects/mlir/include
)
set
(
MLIR_INCLUDE_PATHS
${
MLIR_SRC_INCLUDE_PATH
}
;
${
MLIR_BIN_INCLUDE_PATH
}
)
set
(
MLIR_SRC_INCLUDE_PATH
${
MLIR_SOURCE_DIR
}
/include
)
set
(
MLIR_BIN_INCLUDE_PATH
${
MLIR_BUILD_DIR
}
/projects/mlir/include
)
set
(
MLIR_INCLUDE_PATHS
${
MLIR_SRC_INCLUDE_PATH
}
;
${
MLIR_BIN_INCLUDE_PATH
}
)
else
()
message
(
FATAL_ERROR
"Cannot find ninja. Cannot build with NGRAPH_MLIR_ENABLE=ON"
)
endif
()
cmake/mlir_fetch.cmake.in
View file @
cbdb405e
# ******************************************************************************
# Copyright 2019 Intel Corporation
# Copyright 201
7-201
9 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -45,8 +45,8 @@ ExternalProject_Add(
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
BUILD_COMMAND ${CMAKE_COMMAND}
-G Ninja
../llvm -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_ENABLE_CXX1Y=Y -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_RTTI=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
COMMAND ${CMAKE_COMMAND} --build . --target check-mlir
BUILD_COMMAND ${CMAKE_COMMAND} ../llvm -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_ENABLE_CXX1Y=Y -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_RTTI=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
COMMAND ${CMAKE_COMMAND} --build . --target check-mlir
-- -j8
INSTALL_COMMAND ""
UPDATE_COMMAND ""
SOURCE_DIR ${MLIR_SOURCE_DIR}
...
...
src/contrib/mlir/CMakeLists.txt
View file @
cbdb405e
# ******************************************************************************
# Copyright 2019 Intel Corporation
# Copyright 201
7-201
9 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -103,9 +103,7 @@ if (NGRAPH_MLIR_ENABLE)
set
(
TABLEGEN_OUTPUT
${
TABLEGEN_OUTPUT
}
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
ofn
}
PARENT_SCOPE
)
endfunction
()
set
(
MLIR_TABLEGEN_EXE mlir-tblgen
)
set
(
LLVM_TARGET_DEFINITIONS dialect/ops.td
)
ngraph_tablegen
(
ops.h.inc -gen-op-decls
)
...
...
@@ -114,5 +112,4 @@ if (NGRAPH_MLIR_ENABLE)
add_public_tablegen_target
(
ngraph_ops_gen
)
add_dependencies
(
mlir_backend ngraph_ops_gen
)
target_include_directories
(
mlir_backend PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
)
endif
()
src/contrib/mlir/compiler.cpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -161,12 +161,19 @@ mlir::Type MLIRCompiler::get_mlir_type(const descriptor::Tensor* tensor)
// Converts an nGraph element type into an MLIR type.
mlir
::
Type
MLIRCompiler
::
get_mlir_type
(
const
element
::
Type
&
type
)
{
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch
(
type
.
get_type_enum
())
{
case
ngraph
:
:
element
::
Type_t
::
undefined
:
case
ngraph
:
:
element
::
Type_t
::
dynamic
:
default
:
NGRAPH_FAIL
()
<<
"MLIR: Unsupported NGraph types"
;
break
;
case
ngraph
:
:
element
::
Type_t
::
bf16
:
return
mlir
::
NGFloatType
::
getBF16
(
&
m_context
);
case
ngraph
:
:
element
::
Type_t
::
f16
:
return
mlir
::
NGFloatType
::
getF16
(
&
m_context
);
case
ngraph
:
:
element
::
Type_t
::
f32
:
return
mlir
::
NGFloatType
::
getF32
(
&
m_context
);
case
ngraph
:
:
element
::
Type_t
::
f64
:
return
mlir
::
NGFloatType
::
getF64
(
&
m_context
);
case
ngraph
:
:
element
::
Type_t
::
i8
:
return
mlir
::
NGIntegerType
::
getInt8
(
&
m_context
);
...
...
@@ -181,6 +188,10 @@ mlir::Type MLIRCompiler::get_mlir_type(const element::Type& type)
}
NGRAPH_FAIL
()
<<
"Unreachable"
;
return
mlir
::
Type
();
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop
#endif
}
void
MLIRCompiler
::
update_tensor_value
(
descriptor
::
Tensor
*
tensor
,
mlir
::
Value
*
value
)
...
...
src/contrib/mlir/compiler.hpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/dialect/dialect.cpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/dialect/ops.cpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/dialect/ops.hpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/dialect/ops.td
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/dialect/type.cpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/dialect/type.hpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/lowerer.cpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/lowerer.hpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/memory_manager.cpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/memory_manager.hpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/op_lowerers.inc
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
src/contrib/mlir/pass/mlir_subgraph_extraction.cpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -36,7 +36,9 @@ bool MLIRSubgraphExtractionPass::run_on_function(std::shared_ptr<Function> func)
{
// All ops must be supported by MLIR compiler
if
(
!
is_supported_mlir_op
(
op
))
{
return
false
;
}
if
(
TI
(
Parameter
)
!=
TI
(
*
op
)
&&
TI
(
Result
)
!=
TI
(
*
op
))
{
...
...
@@ -52,7 +54,9 @@ bool MLIRSubgraphExtractionPass::run_on_function(std::shared_ptr<Function> func)
NodeVector
ck_outputs
=
std
::
move
(
get_subgraph_outputs
(
ck_ops
,
{}
/*exclusions*/
));
if
(
ck_outputs
.
size
()
!=
1
)
{
return
false
;
}
auto
ck
=
std
::
make_shared
<
CompiledKernel
>
(
ck_ops
,
ck_outputs
,
ck_args
);
...
...
@@ -81,11 +85,15 @@ bool MLIRSubgraphExtractionPass::run_on_function(std::shared_ptr<Function> func)
bool
MLIRSubgraphExtractionPass
::
is_supported_mlir_op
(
std
::
shared_ptr
<
Node
>
node
)
{
if
(
TI
(
Parameter
)
==
TI
(
*
node
)
||
TI
(
Result
)
==
TI
(
*
node
))
{
return
true
;
}
// supported by backend ?
if
(
m_supported_ops
.
find
(
TI
(
*
node
))
==
m_supported_ops
.
end
())
{
return
false
;
}
// check on invariants expected by MLIR backend
...
...
@@ -93,8 +101,10 @@ bool MLIRSubgraphExtractionPass::is_supported_mlir_op(std::shared_ptr<Node> node
if
(
TI
(
ngraph
::
op
::
Dot
)
==
TI
(
*
node
))
{
if
(
node
->
get_input_shape
(
0
).
size
()
!=
2
||
node
->
get_input_shape
(
1
).
size
()
!=
2
)
{
return
false
;
}
}
return
true
;
}
...
...
src/contrib/mlir/pass/mlir_subgraph_extraction.hpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 2019 Intel Corporation
// Copyright 201
7-201
9 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -32,7 +32,6 @@ namespace ngraph
MLIRSubgraphExtractionPass
()
{}
bool
run_on_function
(
std
::
shared_ptr
<
Function
>
func
)
override
;
/// Checks if an ngraph node is supported by MLIR backend
/// Currently this check is only valid for CPU backend.
bool
is_supported_mlir_op
(
std
::
shared_ptr
<
Node
>
node
);
private
:
...
...
src/ngraph/runtime/cpu/builder/mlir_cpu_compiled_kernel.cpp
View file @
cbdb405e
//*****************************************************************************
// Copyright 201
8
-2019 Intel Corporation
// Copyright 201
7
-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
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