Commit d755e693 authored by Nagy Mostafa's avatar Nagy Mostafa Committed by Scott Cyphers

[MLIR] Create a separate mlir core lib (#4121)

* separate mlir core to a lib

* rename in one more file

* change core lib linking to PUBLIC
parent 862a34d3
......@@ -18,34 +18,27 @@ include_directories(
${NGRAPH_INCLUDE_PATH}
${MLIR_LLVM_INCLUDE_PATH}
${MLIR_INCLUDE_PATHS}
${CMAKE_CURRENT_BINARY_DIR}
)
add_subdirectory(tools/ngraph-opt)
add_subdirectory(core)
set(SRC
backend/cpu/cpu_backend.cpp
backend/pass/affine_lowerer.cpp
backend/pass/memory_optimization.cpp
core/compiler.cpp
core/ngraph_dialect/dialect.cpp
core/ngraph_dialect/type.cpp
core/ngraph_dialect/ops.cpp
core/pass/mlir_subgraph_extraction.cpp
core/pass/mlir_subgraph_extraction.hpp
core/pass/ng_dialect_builder.cpp
core/pass/ng_dialect_builder.hpp
runtime/cpu/memory_manager.cpp
runtime/cpu/cpu_runtime.cpp
utils.cpp
)
add_library(mlir_backend SHARED ${SRC})
add_library(mlir_cpu_backend SHARED ${SRC})
llvm_map_components_to_libnames(llvm_libs support core irreader)
# Link MLIR libs
target_link_libraries(
mlir_backend PRIVATE
mlir_cpu_backend PRIVATE
MLIRAffineToStandard
MLIRAnalysis
MLIREDSC
......@@ -59,6 +52,11 @@ target_link_libraries(
MLIRTransforms
MLIRSupport
)
target_link_libraries(
mlir_cpu_backend PUBLIC
mlir_core
)
# some libs need whole archive linkage because of Globals static initialization
function(whole_archive_link target)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
......@@ -82,15 +80,15 @@ set(LIBS
${LLVM_BUILD_LIBRARY_DIR}/libMLIRAffineOps.a
${LLVM_BUILD_LIBRARY_DIR}/libMLIRStandardOps.a
)
whole_archive_link(mlir_backend ${LIBS})
whole_archive_link(mlir_cpu_backend ${LIBS})
# Link LLVM libs
target_link_libraries(
mlir_backend PRIVATE
mlir_cpu_backend PRIVATE
${llvm_libs}
)
# Link ngraph
target_link_libraries(mlir_backend PUBLIC ngraph)
target_link_libraries(mlir_cpu_backend PUBLIC ngraph)
# table-gen dialect ops
# include table-gen helpers
......@@ -122,8 +120,6 @@ ngraph_tablegen(ops_attributes.h.inc -gen-enum-decls)
ngraph_tablegen(ops_attributes.cpp.inc -gen-enum-defs)
add_public_tablegen_target(ngraph_ops_attributes_gen)
add_dependencies(mlir_backend ngraph_ops_gen ngraph_ops_interfaces_gen ngraph_ops_attributes_gen)
target_include_directories(mlir_backend PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(mlir_cpu_backend ngraph_ops_gen ngraph_ops_interfaces_gen ngraph_ops_attributes_gen)
install(TARGETS mlir_backend DESTINATION ${NGRAPH_INSTALL_LIB})
install(TARGETS mlir_cpu_backend DESTINATION ${NGRAPH_INSTALL_LIB})
# ******************************************************************************
# Copyright 2017-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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ******************************************************************************
include_directories(
${NGRAPH_INCLUDE_PATH}
${MLIR_LLVM_INCLUDE_PATH}
${MLIR_INCLUDE_PATHS}
)
set(SRC
compiler.cpp
ngraph_dialect/dialect.cpp
ngraph_dialect/type.cpp
ngraph_dialect/ops.cpp
pass/mlir_subgraph_extraction.cpp
pass/mlir_subgraph_extraction.hpp
pass/ng_dialect_builder.cpp
pass/ng_dialect_builder.hpp
)
add_library(mlir_core SHARED ${SRC})
......@@ -15,7 +15,7 @@
# ******************************************************************************
set(LIBS
mlir_backend
mlir_cpu_backend
MLIROptMain
MLIRPass
MLIRParser
......
......@@ -276,9 +276,9 @@ if (NGRAPH_CPU_ENABLE)
DEFINITION MLIR_LLVM_INCLUDEPATH)
message(STATUS "Building CPU backend with MLIR")
add_dependencies(cpu_backend mlir_backend)
add_dependencies(cpu_backend mlir_cpu_backend)
target_include_directories(cpu_backend PUBLIC ${MLIR_INCLUDE_PATHS} ${MLIR_LLVM_INCLUDE_PATH})
target_link_libraries(cpu_backend PUBLIC mlir_backend)
target_link_libraries(cpu_backend PUBLIC mlir_cpu_backend)
# TODO: Get rid of the compile time def, and move all MLIR code to separate src files
# and add them to cpu_backend here instead.
target_compile_definitions(cpu_backend PRIVATE "NGRAPH_MLIR_ENABLE")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment