Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cld
ml
tvm
Commits
4be6a307
Commit
4be6a307
authored
6 years ago
by
abergeron
Committed by
Tianqi Chen
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Unite cmake builds (#1248)
parent
5a15664e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+34
-6
34 additions, 6 deletions
CMakeLists.txt
nnvm/CMakeLists.txt
+0
-140
0 additions, 140 deletions
nnvm/CMakeLists.txt
nnvm/cmake/Utils.cmake
+0
-402
0 additions, 402 deletions
nnvm/cmake/Utils.cmake
nnvm/python/nnvm/libinfo.py
+6
-6
6 additions, 6 deletions
nnvm/python/nnvm/libinfo.py
with
40 additions
and
554 deletions
CMakeLists.txt
+
34
−
6
View file @
4be6a307
...
...
@@ -34,6 +34,7 @@ tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF)
tvm_option
(
USE_CUDNN
"Build with cuDNN"
OFF
)
include_directories
(
BEFORE
"nnvm/include"
)
include_directories
(
"include"
)
include_directories
(
"HalideIR/src"
)
include_directories
(
"dlpack/include"
)
...
...
@@ -68,8 +69,9 @@ else(MSVC)
endif
(
MSVC
)
# add source group
FILE
(
GLOB_RECURSE GROUP_SOURCE
"src/*.cc"
"HalideIR/src/*.cpp"
)
FILE
(
GLOB_RECURSE GROUP_Include
"src/*.h"
"include/*.h"
"HalideIR/src/*.h"
)
FILE
(
GLOB_RECURSE GROUP_SOURCE
"src/*.cc"
"HalideIR/src/*.cpp"
"nnvm/src/*.cc"
)
FILE
(
GLOB_RECURSE GROUP_Include
"src/*.h"
"include/*.h"
"HalideIR/src/*.h"
"nnvm/src/*.h"
"nnvm/include/*.h"
)
assign_source_group
(
"Source"
${
GROUP_SOURCE
}
)
assign_source_group
(
"Include"
${
GROUP_Include
}
)
...
...
@@ -82,7 +84,16 @@ file(GLOB COMPILER_SRCS
src/pass/*.cc
src/op/*.cc
src/schedule/*.cc
)
)
file
(
GLOB_RECURSE NNVM_COMPILER_SRCS
nnvm/src/c_api/*.cc
nnvm/src/core/*.cc
nnvm/src/pass/*.cc
nnvm/src/compiler/*.cc
nnvm/src/top/*.cc
)
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/topi/include
)
file
(
GLOB TOPI_SRCS
topi/src/*.cc
...
...
@@ -252,10 +263,21 @@ list(APPEND RUNTIME_SRCS ${GROUP_Include})
add_library
(
tvm SHARED
${
COMPILER_SRCS
}
${
RUNTIME_SRCS
}
)
add_library
(
tvm_topi SHARED
${
TOPI_SRCS
}
)
add_library
(
tvm_runtime SHARED
${
RUNTIME_SRCS
}
)
add_library
(
nnvm_compiler SHARED
${
NNVM_COMPILER_SRCS
}
)
target_link_libraries
(
tvm
${
TVM_LINKER_LIBS
}
${
TVM_RUNTIME_LINKER_LIBS
}
)
target_link_libraries
(
tvm_topi tvm
${
TVM_LINKER_LIBS
}
${
TVM_RUNTIME_LINKER_LIBS
}
)
target_link_libraries
(
tvm_runtime
${
TVM_RUNTIME_LINKER_LIBS
}
)
target_link_libraries
(
tvm_runtime
${
TVM_RUNTIME_LINKER_LIBS
}
)
target_link_libraries
(
nnvm_compiler tvm
)
install
(
TARGETS tvm_runtime DESTINATION lib
${
LIB_SUFFIX
}
)
if
(
WIN32
)
install
(
TARGETS nnvm_compiler RUNTIME DESTINATION bin
)
install
(
TARGETS nnvm_compiler ARCHIVE DESTINATION lib
)
else
()
install
(
TARGETS nnvm_compiler LIBRARY DESTINATION lib
)
endif
()
if
(
INSTALL_DEV
)
install
(
TARGETS tvm DESTINATION lib
${
LIB_SUFFIX
}
)
install
(
...
...
@@ -277,13 +299,18 @@ if (INSTALL_DEV)
DIRECTORY
"dlpack/include/."
DESTINATION
"include"
FILES_MATCHING
PATTERN
"*.h"
)
)
install
(
DIRECTORY
"nnvm/include/."
DESTINATION
"include"
FILES_MATCHING
PATTERN
"*.h"
)
else
(
INSTALL_DEV
)
install
(
DIRECTORY
"include/tvm/runtime/."
DESTINATION
"include/tvm/runtime"
FILES_MATCHING
PATTERN
"*.h"
)
)
endif
(
INSTALL_DEV
)
if
(
MSVC
)
...
...
@@ -291,4 +318,5 @@ if(MSVC)
target_compile_definitions
(
tvm_runtime PRIVATE -DHalide_EXPORTS
)
target_compile_definitions
(
tvm PRIVATE -DTVM_EXPORTS
)
target_compile_definitions
(
tvm_runtime PRIVATE -DTVM_EXPORTS
)
target_compile_definitions
(
nnvm_compiler PRIVATE -DNNVM_EXPORTS
)
endif
()
This diff is collapsed.
Click to expand it.
nnvm/CMakeLists.txt
deleted
100644 → 0
+
0
−
140
View file @
5a15664e
cmake_minimum_required
(
VERSION 2.8.7
)
project
(
nnvm C CXX
)
list
(
APPEND CMAKE_MODULE_PATH
${
PROJECT_SOURCE_DIR
}
/cmake/Modules
)
if
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/build/private/local_config.cmake
)
include
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/build/private/local_config.cmake
)
endif
()
include
(
cmake/Utils.cmake
)
if
(
EXISTS
${
CMAKE_CURRENT_BINARY_DIR
}
/config.cmake
)
include
(
${
CMAKE_CURRENT_BINARY_DIR
}
/config.cmake
)
else
()
if
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/config.cmake
)
include
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/config.cmake
)
endif
()
endif
()
# include path
include_directories
(
BEFORE
"include"
)
include_directories
(
"../include"
)
include_directories
(
"../dlpack/include"
)
include_directories
(
"../HalideIR/src"
)
include_directories
(
"../topi/include"
)
set
(
NNVM_LINKER_LIBS
""
)
set
(
NNVM_COMPILER_LINKER_LIBS
""
)
add_definitions
(
-DNNVM_EXPORTS
)
# Build a shared lib (libnnvm.so) by default
option
(
BUILD_SHARED_NNVM
"Build a shared nnvm lib"
ON
)
option
(
BUILD_STATIC_NNVM
"Build a static nnvm lib"
OFF
)
option
(
USE_MSVC_MT
"Build with MT"
OFF
)
# compile
if
(
MSVC
)
add_definitions
(
-DDMLC_USE_CXX11
)
add_definitions
(
-DDMLC_STRICT_CXX11
)
if
(
USE_MSVC_MT
)
foreach
(
flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
if
(
${
flag_var
}
MATCHES
"/MD"
)
string
(
REGEX REPLACE
"/MD"
"/MT"
${
flag_var
}
"
${${
flag_var
}}
"
)
endif
(
${
flag_var
}
MATCHES
"/MD"
)
endforeach
(
flag_var
)
endif
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/EHsc"
)
find_library
(
TVM_LIB tvm
HINTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/../build/Release
)
message
(
STATUS
"Build with TVM libary: "
${
TVM_LIB
}
)
list
(
APPEND NNVM_COMPILER_LINKER_LIBS
${
TVM_LIB
}
)
else
(
MSVC
)
include
(
CheckCXXCompilerFlag
)
check_cxx_compiler_flag
(
"-std=c++11"
SUPPORT_CXX11
)
set
(
CMAKE_C_FLAGS
"-O3 -Wall -std=c++11 -fPIC"
)
set
(
CMAKE_CXX_FLAGS
${
CMAKE_C_FLAGS
}
)
endif
(
MSVC
)
if
(
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Darwin"
)
set
(
CMAKE_SHARED_LINKER_FLAGS
"
${
CMAKE_SHARED_LINKER_FLAGS
}
-undefined dynamic_lookup"
)
endif
()
mxnet_source_group
(
"Include
\\
c_api"
GLOB
"src/c_api/*.h"
)
mxnet_source_group
(
"Include
\\
core"
GLOB
"src/core/*.h"
)
mxnet_source_group
(
"Include
\\
pass"
GLOB
"src/pass/*.h"
)
mxnet_source_group
(
"Include
\\
nnvm"
GLOB
"include/nnvm/*.h"
)
mxnet_source_group
(
"Include
\\
dmlc"
GLOB
"include/dmlc/*.h"
)
mxnet_source_group
(
"Source"
GLOB
"src/*.cc"
)
mxnet_source_group
(
"Source
\\
c_api"
GLOB
"src/c_api/*.cc"
)
mxnet_source_group
(
"Source
\\
core"
GLOB
"src/core/*.cc"
)
mxnet_source_group
(
"Source
\\
pass"
GLOB
"src/pass/*.cc"
)
file
(
GLOB_RECURSE SOURCE
src/c_api/*.cc
src/core/*.cc
src/pass/*.cc
)
file
(
GLOB_RECURSE COMPILER_SRCS
src/compiler/*.cc
src/top/*.cc
)
if
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/../dmlc-core/CMakeLists.txt
)
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../dmlc-core/include
)
elseif
(
DMLC_CORE_PATH
)
include_directories
(
${
DMLC_CORE_PATH
}
/include
)
endif
()
if
(
BUILD_SHARED_NNVM
)
add_library
(
nnvm SHARED
${
SOURCE
}
)
target_link_libraries
(
nnvm
${
nnvm_LINKER_LIBS
}
)
endif
()
if
(
BUILD_STATIC_NNVM
)
add_library
(
nnvm_static STATIC
${
SOURCE
}
)
target_link_libraries
(
nnvm_static
${
nnvm_LINKER_LIBS
}
)
set_target_properties
(
nnvm_static PROPERTIES OUTPUT_NAME
"nnvm"
)
endif
()
add_library
(
nnvm_compiler SHARED
${
COMPILER_SRCS
}
${
SOURCE
}
)
target_link_libraries
(
nnvm_compiler
${
NNVM_COMPILER_LINKER_LIBS
}
${
NNVM_LINKER_LIBS
}
)
if
(
INSTALL_INCLUDE_DIR
)
add_custom_command
(
TARGET nnvm POST_BUILD
COMMAND COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
CMAKE_SOURCE_DIR
}
/include
${
INSTALL_INCLUDE_DIR
}
/
)
endif
()
# ---[ Install lib, header and docs
if
(
BUILD_SHARED_NNVM
)
if
(
WIN32
)
install
(
TARGETS nnvm RUNTIME DESTINATION bin
)
install
(
TARGETS nnvm ARCHIVE DESTINATION lib
)
install
(
TARGETS nnvm_compiler RUNTIME DESTINATION bin
)
install
(
TARGETS nnvm_compiler ARCHIVE DESTINATION lib
)
else
()
install
(
TARGETS nnvm LIBRARY DESTINATION lib
)
install
(
TARGETS nnvm_compiler LIBRARY DESTINATION lib
)
endif
()
endif
()
if
(
BUILD_STATIC_NNVM
)
install
(
TARGETS nnvm_static ARCHIVE DESTINATION lib
)
endif
()
install
(
DIRECTORY include DESTINATION .
)
install
(
DIRECTORY docs DESTINATION .
)
# ---[ Linter target
if
(
MSVC
)
find_package
(
PythonInterp 2
)
set
(
PYTHON2_EXECUTABLE
${
PYTHON_EXECUTABLE
}
CACHE FILEPATH
"Path to the python 2.x executable"
)
find_package
(
PythonInterp 3
)
set
(
PYTHON3_EXECUTABLE
${
PYTHON_EXECUTABLE
}
CACHE FILEPATH
"Path to the python 3.x executable"
)
endif
()
set
(
LINT_DIRS include src scripts
)
add_custom_target
(
nnvm_lint COMMAND
${
CMAKE_COMMAND
}
-DMSVC=
${
MSVC
}
-DPYTHON2_EXECUTABLE=
${
PYTHON2_EXECUTABLE
}
-DPYTHON3_EXECUTABLE=
${
PYTHON3_EXECUTABLE
}
-DPROJECT_SOURCE_DIR=
${
PROJECT_SOURCE_DIR
}
-DLINT_DIRS=
${
LINT_DIRS
}
-DPROJECT_NAME=dmlc -P
${
PROJECT_SOURCE_DIR
}
/cmake/lint.cmake
)
This diff is collapsed.
Click to expand it.
nnvm/cmake/Utils.cmake
deleted
100644 → 0
+
0
−
402
View file @
5a15664e
# For cmake_parse_arguments
include
(
CMakeParseArguments
)
################################################################################################
# Command alias for debugging messages
# Usage:
# dmsg(<message>)
function
(
dmsg
)
message
(
STATUS
${
ARGN
}
)
endfunction
()
################################################################################################
# Removes duplicates from list(s)
# Usage:
# mxnet_list_unique(<list_variable> [<list_variable>] [...])
macro
(
mxnet_list_unique
)
foreach
(
__lst
${
ARGN
}
)
if
(
${
__lst
}
)
list
(
REMOVE_DUPLICATES
${
__lst
}
)
endif
()
endforeach
()
endmacro
()
################################################################################################
# Clears variables from list
# Usage:
# mxnet_clear_vars(<variables_list>)
macro
(
mxnet_clear_vars
)
foreach
(
_var
${
ARGN
}
)
unset
(
${
_var
}
)
endforeach
()
endmacro
()
################################################################################################
# Removes duplicates from string
# Usage:
# mxnet_string_unique(<string_variable>)
function
(
mxnet_string_unique __string
)
if
(
${
__string
}
)
set
(
__list
${${
__string
}}
)
separate_arguments
(
__list
)
list
(
REMOVE_DUPLICATES __list
)
foreach
(
__e
${
__list
}
)
set
(
__str
"
${
__str
}
${
__e
}
"
)
endforeach
()
set
(
${
__string
}
${
__str
}
PARENT_SCOPE
)
endif
()
endfunction
()
################################################################################################
# Prints list element per line
# Usage:
# mxnet_print_list(<list>)
function
(
mxnet_print_list
)
foreach
(
e
${
ARGN
}
)
message
(
STATUS
${
e
}
)
endforeach
()
endfunction
()
################################################################################################
# Function merging lists of compiler flags to single string.
# Usage:
# mxnet_merge_flag_lists(out_variable <list1> [<list2>] [<list3>] ...)
function
(
mxnet_merge_flag_lists out_var
)
set
(
__result
""
)
foreach
(
__list
${
ARGN
}
)
foreach
(
__flag
${${
__list
}}
)
string
(
STRIP
${
__flag
}
__flag
)
set
(
__result
"
${
__result
}
${
__flag
}
"
)
endforeach
()
endforeach
()
string
(
STRIP
${
__result
}
__result
)
set
(
${
out_var
}
${
__result
}
PARENT_SCOPE
)
endfunction
()
################################################################################################
# Converts all paths in list to absolute
# Usage:
# mxnet_convert_absolute_paths(<list_variable>)
function
(
mxnet_convert_absolute_paths variable
)
set
(
__dlist
""
)
foreach
(
__s
${${
variable
}}
)
get_filename_component
(
__abspath
${
__s
}
ABSOLUTE
)
list
(
APPEND __list
${
__abspath
}
)
endforeach
()
set
(
${
variable
}
${
__list
}
PARENT_SCOPE
)
endfunction
()
################################################################################################
# Reads set of version defines from the header file
# Usage:
# mxnet_parse_header(<file> <define1> <define2> <define3> ..)
macro
(
mxnet_parse_header FILENAME FILE_VAR
)
set
(
vars_regex
""
)
set
(
__parnet_scope OFF
)
set
(
__add_cache OFF
)
foreach
(
name
${
ARGN
}
)
if
(
"
${
name
}
"
STREQUAL
"PARENT_SCOPE"
)
set
(
__parnet_scope ON
)
elseif
(
"
${
name
}
"
STREQUAL
"CACHE"
)
set
(
__add_cache ON
)
elseif
(
vars_regex
)
set
(
vars_regex
"
${
vars_regex
}
|
${
name
}
"
)
else
()
set
(
vars_regex
"
${
name
}
"
)
endif
()
endforeach
()
if
(
EXISTS
"
${
FILENAME
}
"
)
file
(
STRINGS
"
${
FILENAME
}
"
${
FILE_VAR
}
REGEX
"#define[
\t
]+(
${
vars_regex
}
)[
\t
]+[0-9]+"
)
else
()
unset
(
${
FILE_VAR
}
)
endif
()
foreach
(
name
${
ARGN
}
)
if
(
NOT
"
${
name
}
"
STREQUAL
"PARENT_SCOPE"
AND NOT
"
${
name
}
"
STREQUAL
"CACHE"
)
if
(
${
FILE_VAR
}
)
if
(
${
FILE_VAR
}
MATCHES
".+[
\t
]
${
name
}
[
\t
]+([0-9]+).*"
)
string
(
REGEX REPLACE
".+[
\t
]
${
name
}
[
\t
]+([0-9]+).*"
"
\\
1"
${
name
}
"
${${
FILE_VAR
}}
"
)
else
()
set
(
${
name
}
""
)
endif
()
if
(
__add_cache
)
set
(
${
name
}
${${
name
}}
CACHE INTERNAL
"
${
name
}
parsed from
${
FILENAME
}
"
FORCE
)
elseif
(
__parnet_scope
)
set
(
${
name
}
"
${${
name
}}
"
PARENT_SCOPE
)
endif
()
else
()
unset
(
${
name
}
CACHE
)
endif
()
endif
()
endforeach
()
endmacro
()
################################################################################################
# Reads single version define from the header file and parses it
# Usage:
# mxnet_parse_header_single_define(<library_name> <file> <define_name>)
function
(
mxnet_parse_header_single_define LIBNAME HDR_PATH VARNAME
)
set
(
${
LIBNAME
}
_H
""
)
if
(
EXISTS
"
${
HDR_PATH
}
"
)
file
(
STRINGS
"
${
HDR_PATH
}
"
${
LIBNAME
}
_H REGEX
"^#define[
\t
]+
${
VARNAME
}
[
\t
]+
\"
[^
\"
]*
\"
.*$"
LIMIT_COUNT 1
)
endif
()
if
(
${
LIBNAME
}
_H
)
string
(
REGEX REPLACE
"^.*[
\t
]
${
VARNAME
}
[
\t
]+
\"
([0-9]+).*$"
"
\\
1"
${
LIBNAME
}
_VERSION_MAJOR
"
${${
LIBNAME
}
_H
}
"
)
string
(
REGEX REPLACE
"^.*[
\t
]
${
VARNAME
}
[
\t
]+
\"
[0-9]+
\\
.([0-9]+).*$"
"
\\
1"
${
LIBNAME
}
_VERSION_MINOR
"
${${
LIBNAME
}
_H
}
"
)
string
(
REGEX REPLACE
"^.*[
\t
]
${
VARNAME
}
[
\t
]+
\"
[0-9]+
\\
.[0-9]+
\\
.([0-9]+).*$"
"
\\
1"
${
LIBNAME
}
_VERSION_PATCH
"
${${
LIBNAME
}
_H
}
"
)
set
(
${
LIBNAME
}
_VERSION_MAJOR
${${
LIBNAME
}
_VERSION_MAJOR
}
${
ARGN
}
PARENT_SCOPE
)
set
(
${
LIBNAME
}
_VERSION_MINOR
${${
LIBNAME
}
_VERSION_MINOR
}
${
ARGN
}
PARENT_SCOPE
)
set
(
${
LIBNAME
}
_VERSION_PATCH
${${
LIBNAME
}
_VERSION_PATCH
}
${
ARGN
}
PARENT_SCOPE
)
set
(
${
LIBNAME
}
_VERSION_STRING
"
${${
LIBNAME
}
_VERSION_MAJOR
}
.
${${
LIBNAME
}
_VERSION_MINOR
}
.
${${
LIBNAME
}
_VERSION_PATCH
}
"
PARENT_SCOPE
)
# append a TWEAK version if it exists:
set
(
${
LIBNAME
}
_VERSION_TWEAK
""
)
if
(
"
${${
LIBNAME
}
_H
}
"
MATCHES
"^.*[
\t
]
${
VARNAME
}
[
\t
]+
\"
[0-9]+
\\
.[0-9]+
\\
.[0-9]+
\\
.([0-9]+).*$"
)
set
(
${
LIBNAME
}
_VERSION_TWEAK
"
${
CMAKE_MATCH_1
}
"
${
ARGN
}
PARENT_SCOPE
)
endif
()
if
(
${
LIBNAME
}
_VERSION_TWEAK
)
set
(
${
LIBNAME
}
_VERSION_STRING
"
${${
LIBNAME
}
_VERSION_STRING
}
.
${${
LIBNAME
}
_VERSION_TWEAK
}
"
${
ARGN
}
PARENT_SCOPE
)
else
()
set
(
${
LIBNAME
}
_VERSION_STRING
"
${${
LIBNAME
}
_VERSION_STRING
}
"
${
ARGN
}
PARENT_SCOPE
)
endif
()
endif
()
endfunction
()
########################################################################################################
# An option that the user can select. Can accept condition to control when option is available for user.
# Usage:
# mxnet_option(<option_variable> "doc string" <initial value or boolean expression> [IF <condition>])
function
(
mxnet_option variable description value
)
set
(
__value
${
value
}
)
set
(
__condition
""
)
set
(
__varname
"__value"
)
foreach
(
arg
${
ARGN
}
)
if
(
arg STREQUAL
"IF"
OR arg STREQUAL
"if"
)
set
(
__varname
"__condition"
)
else
()
list
(
APPEND
${
__varname
}
${
arg
}
)
endif
()
endforeach
()
unset
(
__varname
)
if
(
"
${
__condition
}
"
STREQUAL
""
)
set
(
__condition 2 GREATER 1
)
endif
()
if
(
${
__condition
}
)
if
(
"
${
__value
}
"
MATCHES
";"
)
if
(
${
__value
}
)
option
(
${
variable
}
"
${
description
}
"
ON
)
else
()
option
(
${
variable
}
"
${
description
}
"
OFF
)
endif
()
elseif
(
DEFINED
${
__value
}
)
if
(
${
__value
}
)
option
(
${
variable
}
"
${
description
}
"
ON
)
else
()
option
(
${
variable
}
"
${
description
}
"
OFF
)
endif
()
else
()
option
(
${
variable
}
"
${
description
}
"
${
__value
}
)
endif
()
else
()
unset
(
${
variable
}
CACHE
)
endif
()
endfunction
()
################################################################################################
# Utility macro for comparing two lists. Used for CMake debugging purposes
# Usage:
# mxnet_compare_lists(<list_variable> <list2_variable> [description])
function
(
mxnet_compare_lists list1 list2 desc
)
set
(
__list1
${${
list1
}}
)
set
(
__list2
${${
list2
}}
)
list
(
SORT __list1
)
list
(
SORT __list2
)
list
(
LENGTH __list1 __len1
)
list
(
LENGTH __list2 __len2
)
if
(
NOT
${
__len1
}
EQUAL
${
__len2
}
)
message
(
FATAL_ERROR
"Lists are not equal.
${
__len1
}
!=
${
__len2
}
.
${
desc
}
"
)
endif
()
foreach
(
__i RANGE 1
${
__len1
}
)
math
(
EXPR __index
"
${
__i
}
- 1"
)
list
(
GET __list1
${
__index
}
__item1
)
list
(
GET __list2
${
__index
}
__item2
)
if
(
NOT
${
__item1
}
STREQUAL
${
__item2
}
)
message
(
FATAL_ERROR
"Lists are not equal. Differ at element
${
__index
}
.
${
desc
}
"
)
endif
()
endforeach
()
endfunction
()
################################################################################################
# Command for disabling warnings for different platforms (see below for gcc and VisualStudio)
# Usage:
# mxnet_warnings_disable(<CMAKE_[C|CXX]_FLAGS[_CONFIGURATION]> -Wshadow /wd4996 ..,)
macro
(
mxnet_warnings_disable
)
set
(
_flag_vars
""
)
set
(
_msvc_warnings
""
)
set
(
_gxx_warnings
""
)
foreach
(
arg
${
ARGN
}
)
if
(
arg MATCHES
"^CMAKE_"
)
list
(
APPEND _flag_vars
${
arg
}
)
elseif
(
arg MATCHES
"^/wd"
)
list
(
APPEND _msvc_warnings
${
arg
}
)
elseif
(
arg MATCHES
"^-W"
)
list
(
APPEND _gxx_warnings
${
arg
}
)
endif
()
endforeach
()
if
(
NOT _flag_vars
)
set
(
_flag_vars CMAKE_C_FLAGS CMAKE_CXX_FLAGS
)
endif
()
if
(
MSVC AND _msvc_warnings
)
foreach
(
var
${
_flag_vars
}
)
foreach
(
warning
${
_msvc_warnings
}
)
set
(
${
var
}
"
${${
var
}}
${
warning
}
"
)
endforeach
()
endforeach
()
elseif
((
CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX
)
AND _gxx_warnings
)
foreach
(
var
${
_flag_vars
}
)
foreach
(
warning
${
_gxx_warnings
}
)
if
(
NOT warning MATCHES
"^-Wno-"
)
string
(
REPLACE
"
${
warning
}
"
""
${
var
}
"
${${
var
}}
"
)
string
(
REPLACE
"-W"
"-Wno-"
warning
"
${
warning
}
"
)
endif
()
set
(
${
var
}
"
${${
var
}}
${
warning
}
"
)
endforeach
()
endforeach
()
endif
()
mxnet_clear_vars
(
_flag_vars _msvc_warnings _gxx_warnings
)
endmacro
()
################################################################################################
# Helper function get current definitions
# Usage:
# mxnet_get_current_definitions(<definitions_variable>)
function
(
mxnet_get_current_definitions definitions_var
)
get_property
(
current_definitions DIRECTORY PROPERTY COMPILE_DEFINITIONS
)
set
(
result
""
)
foreach
(
d
${
current_definitions
}
)
list
(
APPEND result -D
${
d
}
)
endforeach
()
mxnet_list_unique
(
result
)
set
(
${
definitions_var
}
${
result
}
PARENT_SCOPE
)
endfunction
()
################################################################################################
# Helper function get current includes/definitions
# Usage:
# mxnet_get_current_cflags(<cflagslist_variable>)
function
(
mxnet_get_current_cflags cflags_var
)
get_property
(
current_includes DIRECTORY PROPERTY INCLUDE_DIRECTORIES
)
mxnet_convert_absolute_paths
(
current_includes
)
mxnet_get_current_definitions
(
cflags
)
foreach
(
i
${
current_includes
}
)
list
(
APPEND cflags
"-I
${
i
}
"
)
endforeach
()
mxnet_list_unique
(
cflags
)
set
(
${
cflags_var
}
${
cflags
}
PARENT_SCOPE
)
endfunction
()
################################################################################################
# Helper function to parse current linker libs into link directories, libflags and osx frameworks
# Usage:
# mxnet_parse_linker_libs(<mxnet_LINKER_LIBS_var> <directories_var> <libflags_var> <frameworks_var>)
function
(
mxnet_parse_linker_libs mxnet_LINKER_LIBS_variable folders_var flags_var frameworks_var
)
set
(
__unspec
""
)
set
(
__debug
""
)
set
(
__optimized
""
)
set
(
__framework
""
)
set
(
__varname
"__unspec"
)
# split libs into debug, optimized, unspecified and frameworks
foreach
(
list_elem
${${
mxnet_LINKER_LIBS_variable
}}
)
if
(
list_elem STREQUAL
"debug"
)
set
(
__varname
"__debug"
)
elseif
(
list_elem STREQUAL
"optimized"
)
set
(
__varname
"__optimized"
)
elseif
(
list_elem MATCHES
"^-framework[
\t
]+([^
\t
].*)"
)
list
(
APPEND __framework -framework
${
CMAKE_MATCH_1
}
)
else
()
list
(
APPEND
${
__varname
}
${
list_elem
}
)
set
(
__varname
"__unspec"
)
endif
()
endforeach
()
# attach debug or optimized libs to unspecified according to current configuration
if
(
CMAKE_BUILD_TYPE MATCHES
"Debug"
)
set
(
__libs
${
__unspec
}
${
__debug
}
)
else
()
set
(
__libs
${
__unspec
}
${
__optimized
}
)
endif
()
set
(
libflags
""
)
set
(
folders
""
)
# convert linker libraries list to link flags
foreach
(
lib
${
__libs
}
)
if
(
TARGET
${
lib
}
)
list
(
APPEND folders $<TARGET_LINKER_FILE_DIR:
${
lib
}
>
)
list
(
APPEND libflags -l
${
lib
}
)
elseif
(
lib MATCHES
"^-l.*"
)
list
(
APPEND libflags
${
lib
}
)
elseif
(
IS_ABSOLUTE
${
lib
}
)
get_filename_component
(
name_we
${
lib
}
NAME_WE
)
get_filename_component
(
folder
${
lib
}
PATH
)
string
(
REGEX MATCH
"^lib(.*)"
__match
${
name_we
}
)
list
(
APPEND libflags -l
${
CMAKE_MATCH_1
}
)
list
(
APPEND folders
${
folder
}
)
else
()
message
(
FATAL_ERROR
"Logic error. Need to update cmake script"
)
endif
()
endforeach
()
mxnet_list_unique
(
libflags folders
)
set
(
${
folders_var
}
${
folders
}
PARENT_SCOPE
)
set
(
${
flags_var
}
${
libflags
}
PARENT_SCOPE
)
set
(
${
frameworks_var
}
${
__framework
}
PARENT_SCOPE
)
endfunction
()
################################################################################################
# Helper function to detect Darwin version, i.e. 10.8, 10.9, 10.10, ....
# Usage:
# mxnet_detect_darwin_version(<version_variable>)
function
(
mxnet_detect_darwin_version output_var
)
if
(
APPLE
)
execute_process
(
COMMAND /usr/bin/sw_vers -productVersion
RESULT_VARIABLE __sw_vers OUTPUT_VARIABLE __sw_vers_out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
set
(
${
output_var
}
${
__sw_vers_out
}
PARENT_SCOPE
)
else
()
set
(
${
output_var
}
""
PARENT_SCOPE
)
endif
()
endfunction
()
################################################################################################
# Convenient command to setup source group for IDEs that support this feature (VS, XCode)
# Usage:
# caffe_source_group(<group> GLOB[_RECURSE] <globbing_expression>)
function
(
mxnet_source_group group
)
cmake_parse_arguments
(
CAFFE_SOURCE_GROUP
""
""
"GLOB;GLOB_RECURSE"
${
ARGN
}
)
if
(
CAFFE_SOURCE_GROUP_GLOB
)
file
(
GLOB srcs1
${
CAFFE_SOURCE_GROUP_GLOB
}
)
source_group
(
${
group
}
FILES
${
srcs1
}
)
endif
()
if
(
CAFFE_SOURCE_GROUP_GLOB_RECURSE
)
file
(
GLOB_RECURSE srcs2
${
CAFFE_SOURCE_GROUP_GLOB_RECURSE
}
)
source_group
(
${
group
}
FILES
${
srcs2
}
)
endif
()
endfunction
()
This diff is collapsed.
Click to expand it.
nnvm/python/nnvm/libinfo.py
+
6
−
6
View file @
4be6a307
...
...
@@ -29,8 +29,8 @@ def find_lib_path():
lib_name
=
"
nnvm_compiler
"
if
sys
.
platform
.
startswith
(
'
win32
'
)
else
"
libnnvm_compiler
"
api_path
=
os
.
path
.
join
(
base_path
,
'
../../lib/
'
)
cmake_build_path
=
os
.
path
.
join
(
base_path
,
'
../../build/Release/
'
)
cmake_build_path
=
os
.
path
.
join
(
base_path
,
'
../../build/
'
)
cmake_build_path
=
os
.
path
.
join
(
base_path
,
'
../../
../
build/Release/
'
)
cmake_build_path
=
os
.
path
.
join
(
base_path
,
'
../../
../
build/
'
)
dll_path
=
[
base_path
,
api_path
,
cmake_build_path
]
if
sys
.
platform
.
startswith
(
'
linux
'
)
and
os
.
environ
.
get
(
'
LD_LIBRARY_PATH
'
,
None
):
...
...
@@ -43,11 +43,11 @@ def find_lib_path():
if
sys
.
platform
.
startswith
(
'
win32
'
):
vs_configuration
=
'
Release
'
if
platform
.
architecture
()[
0
]
==
'
64bit
'
:
dll_path
.
append
(
os
.
path
.
join
(
base_path
,
'
../../build
'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base_path
,
'
../../windows/x64
'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base_path
,
'
../../
../
build
'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base_path
,
'
../../
../
windows/x64
'
,
vs_configuration
))
else
:
dll_path
.
append
(
os
.
path
.
join
(
base_path
,
'
../../build
'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base_path
,
'
../../windows
'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base_path
,
'
../../
../
build
'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base_path
,
'
../../
../
windows
'
,
vs_configuration
))
dll_path
=
[
os
.
path
.
join
(
p
,
'
%s.dll
'
%
lib_name
)
for
p
in
dll_path
]
elif
sys
.
platform
.
startswith
(
'
darwin
'
):
dll_path
=
[
os
.
path
.
join
(
p
,
'
%s.dylib
'
%
lib_name
)
for
p
in
dll_path
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment