forked from mindspore-Ecosystem/mindspore
Merge pull request !491 from lupengcheng/revert-merge-263-master
This commit is contained in:
commit
5519bce8ae
|
@ -1,4 +1,4 @@
|
||||||
mindspore_add_pkg(dmlc-core
|
mindspore_add_pkg(dmlc_core
|
||||||
VER 0.3
|
VER 0.3
|
||||||
HEAD_ONLY ./
|
HEAD_ONLY ./
|
||||||
URL https://github.com/dmlc/dmlc-core/archive/808f485387f9a03f78fa9f1159f387d0d91b7a28.zip
|
URL https://github.com/dmlc/dmlc-core/archive/808f485387f9a03f78fa9f1159f387d0d91b7a28.zip
|
||||||
|
|
|
@ -1,16 +1,8 @@
|
||||||
set(incubator_tvm_gpu_CFLAGS "-pipe -Wall -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2")
|
set(incubator_tvm_gpu_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
|
||||||
set(incubator_tvm_gpu_CXXFLAGS "-std=c++11 -pipe -Wall -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2")
|
set(incubator_tvm_gpu_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
|
||||||
set(USE_CUDA "ON")
|
|
||||||
mindspore_add_pkg(incubator_tvm_gpu
|
mindspore_add_pkg(incubator_tvm_gpu
|
||||||
VER 0.6.0
|
VER 0.6.0
|
||||||
LIBS tvm
|
HEAD_ONLY ./
|
||||||
URL https://github.com/apache/incubator-tvm/archive/v0.6.0.tar.gz
|
URL https://github.com/apache/incubator-tvm/archive/v0.6.0.tar.gz
|
||||||
MD5 9cbbd32545a776023acabbba270449fe
|
MD5 9cbbd32545a776023acabbba270449fe)
|
||||||
SUBMODULES ${dlpack_DIRPATH} ${dmlc-core_DIRPATH} ${rang_DIRPATH}
|
|
||||||
SOURCEMODULES topi/python/topi python/tvm
|
|
||||||
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/incubator-tvm/find_library.patch
|
|
||||||
${CMAKE_SOURCE_DIR}/third_party/patch/incubator-tvm/include.patch
|
|
||||||
${CMAKE_SOURCE_DIR}/third_party/patch/incubator-tvm/src_pass.patch
|
|
||||||
CMAKE_OPTION -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON)
|
|
||||||
include_directories(${incubator_tvm_gpu_INC})
|
|
||||||
add_library(mindspore::tvm ALIAS incubator_tvm_gpu::tvm)
|
|
||||||
|
|
|
@ -191,17 +191,11 @@ if (ENABLE_GPU)
|
||||||
DESTINATION ${INSTALL_PY_DIR}/../
|
DESTINATION ${INSTALL_PY_DIR}/../
|
||||||
COMPONENT mindspore
|
COMPONENT mindspore
|
||||||
)
|
)
|
||||||
if (EXISTS ${incubator_tvm_gpu_ROOT})
|
if (EXISTS ${CMAKE_BINARY_DIR}/incubator-tvm)
|
||||||
file(GLOB_RECURSE GLOG_LIB_LIST ${incubator_tvm_gpu_LIBPATH}/lib*)
|
|
||||||
install(
|
|
||||||
FILES ${GLOG_LIB_LIST}
|
|
||||||
DESTINATION ${INSTALL_LIB_DIR}
|
|
||||||
COMPONENT mindspore
|
|
||||||
)
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY
|
DIRECTORY
|
||||||
${incubator_tvm_gpu_ROOT}/topi/python/topi
|
${CMAKE_BINARY_DIR}/incubator-tvm/topi/python/topi
|
||||||
${incubator_tvm_gpu_ROOT}/python/tvm
|
${CMAKE_BINARY_DIR}/incubator-tvm/python/tvm
|
||||||
DESTINATION ${INSTALL_PY_DIR}/../_akg
|
DESTINATION ${INSTALL_PY_DIR}/../_akg
|
||||||
COMPONENT mindspore
|
COMPONENT mindspore
|
||||||
)
|
)
|
||||||
|
|
|
@ -206,7 +206,7 @@ function(mindspore_add_pkg pkg_name )
|
||||||
|
|
||||||
set(options )
|
set(options )
|
||||||
set(oneValueArgs URL MD5 GIT_REPOSITORY GIT_TAG VER EXE DIR HEAD_ONLY CMAKE_PATH RELEASE LIB_PATH)
|
set(oneValueArgs URL MD5 GIT_REPOSITORY GIT_TAG VER EXE DIR HEAD_ONLY CMAKE_PATH RELEASE LIB_PATH)
|
||||||
set(multiValueArgs CMAKE_OPTION LIBS PRE_CONFIGURE_COMMAND CONFIGURE_COMMAND BUILD_OPTION INSTALL_INCS INSTALL_LIBS PATCHES SUBMODULES SOURCEMODULES)
|
set(multiValueArgs CMAKE_OPTION LIBS PRE_CONFIGURE_COMMAND CONFIGURE_COMMAND BUILD_OPTION INSTALL_INCS INSTALL_LIBS PATCHES)
|
||||||
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||||
|
|
||||||
if (NOT PKG_LIB_PATH)
|
if (NOT PKG_LIB_PATH)
|
||||||
|
@ -270,21 +270,11 @@ function(mindspore_add_pkg pkg_name )
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (NOT PKG_DIR)
|
if (NOT PKG_DIR)
|
||||||
if (PKG_GIT_REPOSITORY)
|
if (PKG_GIT_REPOSITORY)
|
||||||
__download_pkg_with_git(${pkg_name} ${PKG_GIT_REPOSITORY} ${PKG_GIT_TAG} ${PKG_MD5})
|
__download_pkg_with_git(${pkg_name} ${PKG_GIT_REPOSITORY} ${PKG_GIT_TAG} ${PKG_MD5})
|
||||||
else()
|
else()
|
||||||
__download_pkg(${pkg_name} ${PKG_URL} ${PKG_MD5})
|
__download_pkg(${pkg_name} ${PKG_URL} ${PKG_MD5})
|
||||||
endif()
|
endif()
|
||||||
foreach(_SUBMODULE_FILE ${PKG_SUBMODULES})
|
|
||||||
STRING( REGEX REPLACE "(.+)_(.+)" "\\1" _SUBMODEPATH ${_SUBMODULE_FILE})
|
|
||||||
STRING( REGEX REPLACE "(.+)/(.+)" "\\2" _SUBMODENAME ${_SUBMODEPATH})
|
|
||||||
file(GLOB ${pkg_name}_INSTALL_SUBMODULE ${_SUBMODULE_FILE}/*)
|
|
||||||
file(COPY ${${pkg_name}_INSTALL_SUBMODULE} DESTINATION ${${pkg_name}_SOURCE_DIR}/3rdparty/${_SUBMODENAME})
|
|
||||||
endforeach (_SUBMODULE_FILE)
|
|
||||||
foreach(_SOURCE_DIR ${PKG_SOURCEMODULES})
|
|
||||||
file(GLOB ${pkg_name}_INSTALL_SOURCE ${${pkg_name}_SOURCE_DIR}/${_SOURCE_DIR}/*)
|
|
||||||
file(COPY ${${pkg_name}_INSTALL_SOURCE} DESTINATION ${${pkg_name}_BASE_DIR}/${_SOURCE_DIR}/)
|
|
||||||
endforeach (_SUBMODULE_FILE)
|
|
||||||
else()
|
else()
|
||||||
set(${pkg_name}_SOURCE_DIR ${PKG_DIR})
|
set(${pkg_name}_SOURCE_DIR ${PKG_DIR})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -395,7 +395,114 @@ if(USE_GLOG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_GPU)
|
if(ENABLE_GPU)
|
||||||
target_link_libraries(_c_expression PRIVATE mindspore::tvm)
|
execute_process(COMMAND bash ${CMAKE_SOURCE_DIR}/third_party/apply_patches.sh
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${dlpack_DIRPATH}
|
||||||
|
${dmlc_core_DIRPATH}
|
||||||
|
${rang_DIRPATH}
|
||||||
|
${incubator_tvm_gpu_DIRPATH})
|
||||||
|
set(TVM_DIR "${CMAKE_BINARY_DIR}/incubator-tvm")
|
||||||
|
# Utility functions
|
||||||
|
include(${TVM_DIR}/cmake/util/Util.cmake)
|
||||||
|
include(${TVM_DIR}/cmake/util/FindCUDA.cmake)
|
||||||
|
|
||||||
|
# include directories
|
||||||
|
include_directories(AFTER "${TVM_DIR}/include")
|
||||||
|
include_directories(AFTER "${TVM_DIR}/src")
|
||||||
|
include_directories(AFTER "${TVM_DIR}")
|
||||||
|
include_directories(AFTER "${TVM_DIR}/src/schedule")
|
||||||
|
|
||||||
|
include_directories(AFTER "${TVM_DIR}/3rdparty/dmlc-core/include")
|
||||||
|
include_directories(AFTER "${TVM_DIR}/3rdparty/dlpack/include")
|
||||||
|
include_directories(AFTER "${TVM_DIR}/3rdparty/compiler-rt")
|
||||||
|
include_directories(AFTER "${TVM_DIR}/3rdparty/rang/include")
|
||||||
|
|
||||||
|
# lib contain dlopen and dlclose
|
||||||
|
set(TVM_RUNTIME_LINKER_LIBS ${CMAKE_DL_LIBS})
|
||||||
|
|
||||||
|
# add source group
|
||||||
|
file(GLOB_RECURSE GROUP_SOURCE "${TVM_DIR}/src/*.cc" "src/*.cc")
|
||||||
|
file(GLOB_RECURSE GROUP_INCLUDE "${TVM_DIR}/src/*.h"
|
||||||
|
"${TVM_DIR}/include/*.h" "src/*.h" "include/*.h")
|
||||||
|
assign_source_group("Source" ${GROUP_SOURCE})
|
||||||
|
assign_source_group("Include" ${GROUP_INCLUDE})
|
||||||
|
|
||||||
|
file(GLOB COMPILER_SRCS
|
||||||
|
"pre_activate/gpu/*.cc"
|
||||||
|
${TVM_DIR}/src/api/*.cc
|
||||||
|
${TVM_DIR}/src/arithmetic/*.cc
|
||||||
|
${TVM_DIR}/src/autotvm/*.cc
|
||||||
|
${TVM_DIR}/src/codegen/*.cc
|
||||||
|
${TVM_DIR}/src/lang/*.cc
|
||||||
|
${TVM_DIR}/src/pass/*.cc
|
||||||
|
${TVM_DIR}/src/op/*.cc
|
||||||
|
${TVM_DIR}/src/node/*.cc
|
||||||
|
${TVM_DIR}/src/schedule/*.cc
|
||||||
|
${TVM_DIR}/src/runtime/*.cc
|
||||||
|
${TVM_DIR}/src/runtime/vm/*.cc
|
||||||
|
${TVM_DIR}/src/runtime/vm/profiler/*.cc
|
||||||
|
${TVM_DIR}/src/codegen/stackvm/*.cc)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE RELAY_SRCS ${TVM_DIR}/src/relay/*.cc)
|
||||||
|
list(APPEND COMPILER_SRCS ${RELAY_SRCS})
|
||||||
|
|
||||||
|
file(GLOB DATATYPE_SRCS ${TVM_DIR}/src/codegen/datatype/*.cc)
|
||||||
|
list(APPEND COMPILER_SRCS ${DATATYPE_SRCS})
|
||||||
|
|
||||||
|
file(GLOB COMPILER_VERILOG_SRCS ${TVM_DIR}/src/codegen/verilog/*.cc)
|
||||||
|
list(APPEND COMPILER_SRCS ${COMPILER_VERILOG_SRCS})
|
||||||
|
|
||||||
|
file(GLOB TOPI_SRCS ${TVM_DIR}/topi/src/*.cc)
|
||||||
|
|
||||||
|
file(GLOB RUNTIME_SRCS
|
||||||
|
${TVM_DIR}/src/runtime/*.cc
|
||||||
|
${TVM_DIR}/src/runtime/vm/*.cc
|
||||||
|
${TVM_DIR}/src/runtime/stub/*.cc
|
||||||
|
${TVM_DIR}/src/runtime/stackvm/*.cc)
|
||||||
|
|
||||||
|
|
||||||
|
file(GLOB COMPILER_OFF_SRCS
|
||||||
|
${TVM_DIR}/src/codegen/opt/build_*_off.cc)
|
||||||
|
set(USE_CUDA "OFF")
|
||||||
|
if(ENABLE_GPU)
|
||||||
|
list(REMOVE_ITEM COMPILER_OFF_SRCS
|
||||||
|
${TVM_DIR}/src/codegen/opt/build_cuda_off.cc)
|
||||||
|
set(USE_CUDA "ON")
|
||||||
|
endif()
|
||||||
|
list(APPEND COMPILER_SRCS ${COMPILER_OFF_SRCS})
|
||||||
|
# Module rules
|
||||||
|
include(${TVM_DIR}/cmake/modules/CUDA.cmake)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_AKG -pipe -Wall -fPIC -fstack-protector-all)
|
||||||
|
set(CMAKE_C_FLAGS_AKG ${CMAKE_C_FLAGS_AKG} -Wl,-z,relro,-z,now,-z,noexecstack)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS_AKG -std=c++11 -pipe -Wall -fPIC -fstack-protector-all)
|
||||||
|
set(CMAKE_CXX_FLAGS_AKG ${CMAKE_CXX_FLAGS_AKG} -Wl,-z,relro,-z,now,-z,noexecstack)
|
||||||
|
|
||||||
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||||
|
message("-- Build in Debug mode")
|
||||||
|
set(CMAKE_C_FLAGS_AKG ${CMAKE_C_FLAGS_AKG} -O0 -g -rdynamic)
|
||||||
|
set(CMAKE_CXX_FLAGS_AKG ${CMAKE_CXX_FLAGS_AKG} -O0 -g -rdynamic)
|
||||||
|
else()
|
||||||
|
message("-- Build in Release mode")
|
||||||
|
set(CMAKE_C_FLAGS_AKG ${CMAKE_C_FLAGS_AKG} -O2 -Werror)
|
||||||
|
set(CMAKE_CXX_FLAGS_AKG ${CMAKE_CXX_FLAGS_AKG} -O2 -Werror)
|
||||||
|
endif()
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION
|
||||||
|
VERSION_GREATER 7.0)
|
||||||
|
set(CMAKE_CXX_FLAGS_AKG ${CMAKE_CXX_FLAGS_AKG} -faligned-new)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(akg OBJECT ${COMPILER_SRCS} ${RUNTIME_SRCS} ${TOPI_SRCS})
|
||||||
|
|
||||||
|
target_link_libraries(akg ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS})
|
||||||
|
target_compile_options(akg PRIVATE
|
||||||
|
$<$<COMPILE_LANGUAGE:C>:${CMAKE_C_FLAGS_AKG}>
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CXX_FLAGS_AKG}>)
|
||||||
|
target_include_directories(akg PRIVATE "${TVM_DIR}/topi/include")
|
||||||
|
|
||||||
|
add_dependencies(_c_expression akg)
|
||||||
|
target_link_libraries(_c_expression PRIVATE akg)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_DUMP_PROTO)
|
if(ENABLE_DUMP_PROTO)
|
||||||
|
|
Loading…
Reference in New Issue