Skip to content

Commit 2412c27

Browse files
authored
Merge branch 'develop' into sfraczek/test-analyzer-mobilenet
2 parents b5f617f + c7b3bfc commit 2412c27

File tree

368 files changed

+9601
-7057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

368 files changed

+9601
-7057
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
| qingqing01 | Qing-Qing Dang |
4444
| reyoung | Yang Yu |
4545
| Superjom | Chun-Wei Yan |
46+
| tensor-tang | Jian Tang |
4647
| tianbingsz | Tian-Bing Xu |
4748
| tpatejko | Tomasz Patejko |
4849
| typhoonzero | Yi Wu |

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_F
4141
option(WITH_AMD_GPU "Compile PaddlePaddle with AMD GPU" OFF)
4242
option(WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND})
4343
option(WITH_MKL "Compile PaddlePaddle with MKL support." ${AVX_FOUND})
44+
option(WITH_NGRAPH "Compile PaddlePaddle with nGraph support." OFF)
4445
option(WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" ON)
4546
option(WITH_TESTING "Compile PaddlePaddle with unit testing" OFF)
4647
option(WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON)
@@ -65,6 +66,8 @@ option(WITH_ARM_FP16 "Use half precision support on armv8.2-a cpu" OFF)
6566
option(WITH_CONTRIB "Compile the third-party contributation" OFF)
6667
option(REPLACE_ENFORCE_GLOG "Replace PADDLE_ENFORCE with glog/CHECK for better debug." OFF)
6768
option(WITH_ANAKIN "Compile with Anakin library" OFF)
69+
option(ANAKIN_BUILD_FAT_BIN "Build anakin cuda fat-bin lib for all device plantform, ignored when WITH_ANAKIN=OFF" OFF)
70+
option(ANAKIN_BUILD_CROSS_PLANTFORM "Build anakin lib for any nvidia device plantform. ignored when WITH_ANAKIN=OFF" ON)
6871
option(WITH_GRPC "Use grpc as the default rpc framework" ${WITH_DISTRIBUTE})
6972
option(WITH_BRPC_RDMA "Use brpc rdma as the rpc protocal" OFF)
7073
option(ON_INFER "Turn on inference optimization." OFF)
@@ -103,6 +106,8 @@ if(ANDROID OR IOS)
103106
"Disable RDMA when cross-compiling for Android and iOS" FORCE)
104107
set(WITH_MKL OFF CACHE STRING
105108
"Disable MKL when cross-compiling for Android and iOS" FORCE)
109+
set(WITH_NGRAPH OFF CACHE STRING
110+
"Disable nGraph when cross-compiling for Android and iOS" FORCE)
106111
set(WITH_GOLANG OFF CACHE STRING
107112
"Disable golang when cross-compiling for Android and iOS" FORCE)
108113

@@ -171,6 +176,7 @@ include(external/protobuf) # download, build, install protobuf
171176
include(external/python) # download, build, install python
172177
include(external/openblas) # download, build, install openblas
173178
include(external/mkldnn) # download, build, install mkldnn
179+
include(external/ngraph) # download, build, install nGraph
174180
include(external/swig) # download, build, install swig
175181
include(external/boost) # download boost
176182
include(external/any) # download libn::any

cmake/external/anakin.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,21 @@ ExternalProject_Add(
5858
-DPROTOBUF_ROOT=${THIRD_PARTY_PATH}/install/protobuf
5959
-DMKLML_ROOT=${THIRD_PARTY_PATH}/install/mklml
6060
-DENABLE_OP_TIMER=${ANAKIN_ENABLE_OP_TIMER}
61+
-DBUILD_FAT_BIN=${ANAKIN_BUILD_FAT_BIN}
62+
-DBUILD_CROSS_PLANTFORM=${ANAKIN_BUILD_CROSS_PLANTFORM}
6163
${EXTERNAL_OPTIONAL_ARGS}
6264
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ANAKIN_INSTALL_DIR}
6365
)
6466

6567
message(STATUS "Anakin for inference is enabled")
6668
message(STATUS "Anakin is set INCLUDE:${ANAKIN_INCLUDE} LIBRARY:${ANAKIN_LIBRARY}")
67-
69+
add_dependencies(extern_anakin protobuf mklml)
6870
add_library(anakin_shared SHARED IMPORTED GLOBAL)
6971
set_property(TARGET anakin_shared PROPERTY IMPORTED_LOCATION ${ANAKIN_SHARED_LIB})
70-
add_dependencies(anakin_shared extern_anakin protobuf mklml)
72+
add_dependencies(anakin_shared extern_anakin)
7173

7274
add_library(anakin_saber SHARED IMPORTED GLOBAL)
7375
set_property(TARGET anakin_saber PROPERTY IMPORTED_LOCATION ${ANAKIN_SABER_LIB})
74-
add_dependencies(anakin_saber extern_anakin protobuf mklml)
76+
add_dependencies(anakin_saber extern_anakin)
7577

7678
list(APPEND external_project_dependencies anakin_shared anakin_saber)

cmake/external/mkldnn.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
3737
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLDNN_INSTALL_DIR}/lib")
3838

3939
INCLUDE_DIRECTORIES(${MKLDNN_INC_DIR}) # For MKLDNN code to include internal headers.
40-
INCLUDE_DIRECTORIES(${THIRD_PARTY_PATH}/install) # For Paddle code to include mkldnn.h
4140

4241
IF(${CBLAS_PROVIDER} STREQUAL "MKLML")
4342
SET(MKLDNN_DEPENDS ${MKLML_PROJECT})
4443
MESSAGE(STATUS "Build MKLDNN with MKLML ${MKLML_ROOT}")
4544
ELSE()
4645
MESSAGE(FATAL_ERROR "Should enable MKLML when build MKLDNN")
4746
ENDIF()
48-
SET(MKLDNN_FLAG "-Wno-error=strict-overflow -Wno-error=unused-result")
47+
SET(MKLDNN_FLAG "-Wno-error=strict-overflow -Wno-error=unused-result -Wno-error=array-bounds")
4948
SET(MKLDNN_FLAG "${MKLDNN_FLAG} -Wno-unused-result -Wno-unused-value")
5049
SET(MKLDNN_CFLAG "${CMAKE_C_FLAGS} ${MKLDNN_FLAG}")
5150
SET(MKLDNN_CXXFLAG "${CMAKE_CXX_FLAGS} ${MKLDNN_FLAG}")
@@ -54,7 +53,7 @@ ExternalProject_Add(
5453
${EXTERNAL_PROJECT_LOG_ARGS}
5554
DEPENDS ${MKLDNN_DEPENDS}
5655
GIT_REPOSITORY "https://github.com/01org/mkl-dnn.git"
57-
GIT_TAG "64e03a1939e0d526aa8e9f2e3f7dc0ad8d372944"
56+
GIT_TAG "21fb5f2af1dd14e132af4f1b79160977ee487818"
5857
PREFIX ${MKLDNN_SOURCES_DIR}
5958
UPDATE_COMMAND ""
6059
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}

cmake/external/ngraph.cmake

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
add_library(ngraph INTERFACE)
16+
17+
IF(WIN32 OR APPLE)
18+
MESSAGE(WARNING
19+
"Windows or Mac is not supported with nGraph in Paddle yet."
20+
"Force WITH_NGRAPH=OFF")
21+
SET(WITH_NGRAPH OFF CACHE STRING "Disable nGraph in Windows and MacOS" FORCE)
22+
ENDIF()
23+
24+
IF(${WITH_NGRAPH} AND NOT ${WITH_MKLDNN})
25+
MESSAGE(WARNING
26+
"nGraph needs mkl-dnn to be enabled."
27+
"Force WITH_NGRAPH=OFF")
28+
SET(WITH_NGRAPH OFF CACHE STRING "Disable nGraph if mkl-dnn is disabled" FORCE)
29+
ENDIF()
30+
31+
IF(NOT ${WITH_NGRAPH})
32+
return()
33+
ENDIF()
34+
35+
INCLUDE(ExternalProject)
36+
37+
SET(NGRAPH_PROJECT "extern_ngraph")
38+
SET(NGRAPH_VERSION "0.9")
39+
SET(NGRAPH_GIT_TAG "f9fd9d4cc318dc59dd4b68448e7fbb5f67a28bd0")
40+
SET(NGRAPH_SOURCES_DIR ${THIRD_PARTY_PATH}/ngraph)
41+
SET(NGRAPH_INSTALL_DIR ${THIRD_PARTY_PATH}/install/ngraph)
42+
SET(NGRAPH_INC_DIR ${NGRAPH_INSTALL_DIR}/include)
43+
SET(NGRAPH_SHARED_LIB_NAME libngraph.so.${NGRAPH_VERSION})
44+
SET(NGRAPH_CPU_LIB_NAME libcpu_backend.so)
45+
SET(NGRAPH_TBB_LIB_NAME libtbb.so.2)
46+
SET(NGRAPH_GIT_REPO "https://github.com/NervanaSystems/ngraph.git")
47+
48+
ExternalProject_Add(
49+
${NGRAPH_PROJECT}
50+
${EXTERNAL_PROJECT_LOG_ARGS}
51+
DEPENDS ${MKLDNN_PROJECT} ${MKLML_PROJECT}
52+
GIT_REPOSITORY ${NGRAPH_GIT_REPO}
53+
GIT_TAG ${NGRAPH_GIT_TAG}
54+
PREFIX ${NGRAPH_SOURCES_DIR}
55+
UPDATE_COMMAND ""
56+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${NGRAPH_INSTALL_DIR}
57+
CMAKE_ARGS -DNGRAPH_UNIT_TEST_ENABLE=FALSE
58+
CMAKE_ARGS -DNGRAPH_TOOLS_ENABLE=FALSE
59+
CMAKE_ARGS -DNGRAPH_INTERPRETER_ENABLE=FALSE
60+
CMAKE_ARGS -DNGRAPH_DEX_ONLY=TRUE
61+
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
62+
CMAKE_ARGS -DMKLDNN_INCLUDE_DIR=${MKLDNN_INC_DIR}
63+
CMAKE_ARGS -DMKLDNN_LIB_DIR=${MKLDNN_INSTALL_DIR}/lib
64+
)
65+
66+
if(UNIX AND NOT APPLE)
67+
include(GNUInstallDirs)
68+
SET(NGRAPH_LIB_DIR ${NGRAPH_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR})
69+
else()
70+
SET(NGRAPH_LIB_DIR ${NGRAPH_INSTALL_DIR}/lib)
71+
endif()
72+
MESSAGE(STATUS "nGraph lib will be installed at: ${NGRAPH_LIB_DIR}")
73+
74+
SET(NGRAPH_SHARED_LIB ${NGRAPH_LIB_DIR}/${NGRAPH_SHARED_LIB_NAME})
75+
SET(NGRAPH_CPU_LIB ${NGRAPH_LIB_DIR}/${NGRAPH_CPU_LIB_NAME})
76+
SET(NGRAPH_TBB_LIB ${NGRAPH_LIB_DIR}/${NGRAPH_TBB_LIB_NAME})
77+
78+
# Workaround for nGraph expecting mklml to be in mkldnn install directory.
79+
ExternalProject_Add_Step(
80+
${NGRAPH_PROJECT}
81+
PrepareMKL
82+
COMMAND ${CMAKE_COMMAND} -E create_symlink ${MKLML_LIB} ${MKLDNN_INSTALL_DIR}/lib/libmklml_intel.so
83+
COMMAND ${CMAKE_COMMAND} -E create_symlink ${MKLML_IOMP_LIB} ${MKLDNN_INSTALL_DIR}/lib/libiomp5.so
84+
DEPENDEES download
85+
DEPENDERS configure
86+
)
87+
88+
add_dependencies(ngraph ${NGRAPH_PROJECT})
89+
target_compile_definitions(ngraph INTERFACE -DPADDLE_WITH_NGRAPH)
90+
target_include_directories(ngraph INTERFACE ${NGRAPH_INC_DIR})
91+
target_link_libraries(ngraph INTERFACE ${NGRAPH_SHARED_LIB})
92+
LIST(APPEND external_project_dependencies ngraph)

cmake/external/protobuf.cmake

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -30,66 +30,61 @@ UNSET_VAR(PROTOBUF_LITE_LIBRARY)
3030
UNSET_VAR(PROTOBUF_LIBRARY)
3131
UNSET_VAR(PROTOBUF_INCLUDE_DIR)
3232
UNSET_VAR(Protobuf_PROTOC_EXECUTABLE)
33+
function(protobuf_generate_python SRCS)
34+
# shameless copy from https://github.com/Kitware/CMake/blob/master/Modules/FindProtobuf.cmake
35+
if(NOT ARGN)
36+
message(SEND_ERROR "Error: PROTOBUF_GENERATE_PYTHON() called without any proto files")
37+
return()
38+
endif()
3339

34-
if(NOT COMMAND protobuf_generate_python) # before cmake 3.4, protobuf_genrerate_python is not defined.
35-
function(protobuf_generate_python SRCS)
36-
# shameless copy from https://github.com/Kitware/CMake/blob/master/Modules/FindProtobuf.cmake
37-
if(NOT ARGN)
38-
message(SEND_ERROR "Error: PROTOBUF_GENERATE_PYTHON() called without any proto files")
39-
return()
40-
endif()
41-
42-
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
43-
# Create an include path for each file specified
44-
foreach(FIL ${ARGN})
45-
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
46-
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
47-
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
48-
if(${_contains_already} EQUAL -1)
49-
list(APPEND _protobuf_include_path -I ${ABS_PATH})
50-
endif()
51-
endforeach()
52-
else()
53-
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
54-
endif()
55-
56-
if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS)
57-
set(Protobuf_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}")
58-
endif()
59-
60-
if(DEFINED Protobuf_IMPORT_DIRS)
61-
foreach(DIR ${Protobuf_IMPORT_DIRS})
62-
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
63-
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
64-
if(${_contains_already} EQUAL -1)
65-
list(APPEND _protobuf_include_path -I ${ABS_PATH})
66-
endif()
67-
endforeach()
68-
endif()
69-
70-
set(${SRCS})
40+
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
41+
# Create an include path for each file specified
7142
foreach(FIL ${ARGN})
7243
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
73-
get_filename_component(FIL_WE ${FIL} NAME_WE)
74-
if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH)
75-
get_filename_component(FIL_DIR ${FIL} DIRECTORY)
76-
if(FIL_DIR)
77-
set(FIL_WE "${FIL_DIR}/${FIL_WE}")
78-
endif()
44+
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
45+
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
46+
if(${_contains_already} EQUAL -1)
47+
list(APPEND _protobuf_include_path -I ${ABS_PATH})
7948
endif()
49+
endforeach()
50+
else()
51+
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
52+
endif()
53+
if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS)
54+
set(Protobuf_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}")
55+
endif()
8056

81-
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py")
82-
add_custom_command(
83-
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py"
84-
COMMAND ${Protobuf_PROTOC_EXECUTABLE} --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
85-
DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
86-
COMMENT "Running Python protocol buffer compiler on ${FIL}"
87-
VERBATIM )
57+
if(DEFINED Protobuf_IMPORT_DIRS)
58+
foreach(DIR ${Protobuf_IMPORT_DIRS})
59+
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
60+
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
61+
if(${_contains_already} EQUAL -1)
62+
list(APPEND _protobuf_include_path -I ${ABS_PATH})
63+
endif()
8864
endforeach()
65+
endif()
8966

90-
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
91-
endfunction()
92-
endif()
67+
set(${SRCS})
68+
foreach(FIL ${ARGN})
69+
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
70+
get_filename_component(FIL_WE ${FIL} NAME_WE)
71+
if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH)
72+
get_filename_component(FIL_DIR ${FIL} DIRECTORY)
73+
if(FIL_DIR)
74+
set(FIL_WE "${FIL_DIR}/${FIL_WE}")
75+
endif()
76+
endif()
77+
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py")
78+
add_custom_command(
79+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py"
80+
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
81+
DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
82+
COMMENT "Running Python protocol buffer compiler on ${FIL}"
83+
VERBATIM )
84+
endforeach()
85+
86+
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
87+
endfunction()
9388

9489
# Print and set the protobuf library information,
9590
# finish this cmake process and exit from this file.
@@ -126,6 +121,7 @@ macro(PROMPT_PROTOBUF_LIB)
126121
# FIND_Protobuf.cmake uses `Protobuf_PROTOC_EXECUTABLE`.
127122
# make `protobuf_generate_cpp` happy.
128123
SET(Protobuf_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE})
124+
129125
FOREACH(dep ${protobuf_DEPS})
130126
ADD_DEPENDENCIES(protobuf ${dep})
131127
ADD_DEPENDENCIES(protobuf_lite ${dep})

cmake/inference_lib.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ endif()
164164
set(module "inference")
165165
copy(inference_lib DEPS ${inference_deps}
166166
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/inference/libpaddle_fluid.*
167-
${src_dir}/${module}/api/paddle_inference_api.h
167+
${src_dir}/${module}/api/paddle_*.h
168168
${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/paddle_inference_pass.h
169169
DSTS ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module}
170170
)
@@ -202,10 +202,10 @@ copy(third_party DEPS fluid_lib_dist
202202
DSTS ${FLUID_INFERENCE_INSTALL_DIR} ${FLUID_INFERENCE_INSTALL_DIR}
203203
)
204204

205-
# only need libpaddle_fluid.so/a and paddle_inference_api.h for inference-only library
205+
# only need libpaddle_fluid.so/a and paddle_*.h for inference-only library
206206
copy(inference_api_lib DEPS fluid_lib_dist
207207
SRCS ${FLUID_INSTALL_DIR}/paddle/fluid/inference/libpaddle_fluid.*
208-
${FLUID_INSTALL_DIR}/paddle/fluid/inference/paddle_inference_api.h
208+
${FLUID_INSTALL_DIR}/paddle/fluid/inference/paddle_*.h
209209
DSTS ${FLUID_INFERENCE_INSTALL_DIR}/paddle/lib ${FLUID_INFERENCE_INSTALL_DIR}/paddle/include
210210
)
211211

cmake/tensorrt.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ if(TENSORRT_FOUND)
3434
"Current TensorRT version is v${TENSORRT_MAJOR_VERSION}. ")
3535
include_directories(${TENSORRT_INCLUDE_DIR})
3636
list(APPEND EXTERNAL_LIBS ${TENSORRT_LIBRARY})
37+
add_definitions(-DPADDLE_WITH_TENSORRT)
3738
endif()

0 commit comments

Comments
 (0)