Skip to content

Commit d6b5302

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into dev_op_tensor_support
2 parents 5e7aa8c + 0a641ba commit d6b5302

File tree

248 files changed

+3591
-2105
lines changed

Some content is hidden

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

248 files changed

+3591
-2105
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ option(PY_VERSION "Compile PaddlePaddle with python3 support" ${PY_VER
7373
if(NOT PY_VERSION)
7474
set(PY_VERSION 2.7)
7575
endif()
76+
set(PYBIND11_PYTHON_VERSION ${PY_VERSION})
7677

7778
# CMAKE_BUILD_TYPE
7879
if(NOT CMAKE_BUILD_TYPE)
@@ -159,6 +160,7 @@ endif()
159160
########################################################################################
160161

161162
include(external/mklml) # download mklml package
163+
include(external/xbyak) # download xbyak package
162164
include(external/libxsmm) # download, build, install libxsmm
163165
include(external/zlib) # download, build, install zlib
164166
include(external/gflags) # download, build, install gflags
@@ -175,6 +177,7 @@ include(external/any) # download libn::any
175177
include(external/eigen) # download eigen3
176178
include(external/pybind11) # download pybind11
177179
include(external/cares)
180+
include(external/cub)
178181

179182
if(WITH_DISTRIBUTE)
180183
if(WITH_GRPC)
@@ -201,12 +204,11 @@ include(external/snappy) # download snappy
201204
include(external/snappystream)
202205
include(external/threadpool)
203206

207+
set(WITH_ANAKIN OFF CACHE STRING "Disable Anakin first, will add it later." FORCE)
204208
if(WITH_GPU)
205209
include(cuda)
206210
include(tensorrt)
207211
include(external/anakin)
208-
else()
209-
set(WITH_ANAKIN OFF CACHE STRING "Anakin is valid only when GPU is set." FORCE)
210212
endif()
211213

212214
include(cudnn) # set cudnn libraries, must before configure

cmake/configure.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ if(WITH_GPU)
9797
endif()
9898
include_directories(${TENSORRT_INCLUDE_DIR})
9999
endif()
100+
if(WITH_ANAKIN)
101+
if(${CUDA_VERSION_MAJOR} VERSION_LESS 8)
102+
message(FATAL_ERROR "Anakin needs CUDA >= 8.0 to compile")
103+
endif()
104+
if(${CUDNN_MAJOR_VERSION} VERSION_LESS 7)
105+
message(FATAL_ERROR "Anakin needs CUDNN >= 7.0 to compile")
106+
endif()
107+
endif()
100108
elseif(WITH_AMD_GPU)
101109
add_definitions(-DPADDLE_WITH_HIP)
102110
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__HIP_PLATFORM_HCC__")

cmake/external/anakin.cmake

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ if (NOT WITH_ANAKIN)
22
return()
33
endif()
44

5-
set(ANAKIN_INSTALL_DIR "${THIRD_PARTY_PATH}/install/anakin" CACHE PATH
6-
"Anakin install path." FORCE)
7-
set(ANAKIN_INCLUDE "${ANAKIN_INSTALL_DIR}" CACHE STRING "root of Anakin header files")
8-
set(ANAKIN_LIBRARY "${ANAKIN_INSTALL_DIR}" CACHE STRING "path of Anakin library")
5+
INCLUDE(ExternalProject)
6+
set(ANAKIN_SOURCE_DIR ${THIRD_PARTY_PATH}/anakin)
7+
# the anakin install dir is only default one now
8+
set(ANAKIN_INSTALL_DIR ${THIRD_PARTY_PATH}/anakin/src/extern_anakin/output)
9+
set(ANAKIN_INCLUDE ${ANAKIN_INSTALL_DIR})
10+
set(ANAKIN_LIBRARY ${ANAKIN_INSTALL_DIR})
11+
set(ANAKIN_SHARED_LIB ${ANAKIN_LIBRARY}/libanakin.so)
12+
set(ANAKIN_SABER_LIB ${ANAKIN_LIBRARY}/libanakin_saber_common.so)
13+
14+
# TODO(luotao): ANAKIN_MODLE_URL will move to demo ci later.
15+
set(ANAKIN_MODLE_URL "http://paddle-inference-dist.bj.bcebos.com/mobilenet_v2.anakin.bin")
16+
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_SOURCE_DIR}")
17+
execute_process(COMMAND bash -c "cd ${ANAKIN_SOURCE_DIR}; wget -q --no-check-certificate ${ANAKIN_MODLE_URL}")
18+
19+
include_directories(${ANAKIN_INCLUDE})
20+
include_directories(${ANAKIN_INCLUDE}/saber/)
921

1022
set(ANAKIN_COMPILE_EXTRA_FLAGS
1123
-Wno-error=unused-but-set-variable -Wno-unused-but-set-variable
@@ -20,36 +32,33 @@ set(ANAKIN_COMPILE_EXTRA_FLAGS
2032
-Wno-reorder
2133
-Wno-error=cpp)
2234

23-
set(ANAKIN_LIBRARY_URL "https://github.com/pangge/Anakin/releases/download/Version0.1.0/anakin.tar.gz")
24-
25-
# A helper function used in Anakin, currently, to use it, one need to recursively include
26-
# nearly all the header files.
27-
function(fetch_include_recursively root_dir)
28-
if (IS_DIRECTORY ${root_dir})
29-
include_directories(${root_dir})
30-
endif()
31-
32-
file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*)
33-
foreach(sub ${ALL_SUB})
34-
if (IS_DIRECTORY ${root_dir}/${sub})
35-
fetch_include_recursively(${root_dir}/${sub})
36-
endif()
37-
endforeach()
38-
endfunction()
39-
40-
if (NOT EXISTS "${ANAKIN_INSTALL_DIR}")
41-
# download library
42-
message(STATUS "Download Anakin library from ${ANAKIN_LIBRARY_URL}")
43-
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
44-
execute_process(COMMAND bash -c "rm -rf ${ANAKIN_INSTALL_DIR}/*")
45-
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget --no-check-certificate -q ${ANAKIN_LIBRARY_URL}")
46-
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
47-
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin.tar.gz")
48-
endif()
35+
ExternalProject_Add(
36+
extern_anakin
37+
${EXTERNAL_PROJECT_LOG_ARGS}
38+
# TODO(luotao): use PaddlePaddle/Anakin later
39+
GIT_REPOSITORY "https://github.com/luotao1/Anakin"
40+
GIT_TAG "3957ae9263eaa0b1986758dac60a88852afb09be"
41+
PREFIX ${ANAKIN_SOURCE_DIR}
42+
UPDATE_COMMAND ""
43+
CMAKE_ARGS -DUSE_GPU_PLACE=YES
44+
-DUSE_X86_PLACE=YES
45+
-DBUILD_WITH_UNIT_TEST=NO
46+
-DPROTOBUF_ROOT=${THIRD_PARTY_PATH}/install/protobuf
47+
-DMKLML_ROOT=${THIRD_PARTY_PATH}/install/mklml
48+
-DCUDNN_ROOT=${CUDNN_ROOT}
49+
${EXTERNAL_OPTIONAL_ARGS}
50+
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ANAKIN_INSTALL_DIR}
51+
)
4952

50-
if (WITH_ANAKIN)
51-
message(STATUS "Anakin for inference is enabled")
52-
message(STATUS "Anakin is set INCLUDE:${ANAKIN_INCLUDE} LIBRARY:${ANAKIN_LIBRARY}")
53-
fetch_include_recursively(${ANAKIN_INCLUDE})
54-
link_directories(${ANAKIN_LIBRARY})
55-
endif()
53+
message(STATUS "Anakin for inference is enabled")
54+
message(STATUS "Anakin is set INCLUDE:${ANAKIN_INCLUDE} LIBRARY:${ANAKIN_LIBRARY}")
55+
56+
add_library(anakin_shared SHARED IMPORTED GLOBAL)
57+
set_property(TARGET anakin_shared PROPERTY IMPORTED_LOCATION ${ANAKIN_SHARED_LIB})
58+
add_dependencies(anakin_shared extern_anakin protobuf mklml)
59+
60+
add_library(anakin_saber SHARED IMPORTED GLOBAL)
61+
set_property(TARGET anakin_saber PROPERTY IMPORTED_LOCATION ${ANAKIN_SABER_LIB})
62+
add_dependencies(anakin_saber extern_anakin protobuf mklml)
63+
64+
list(APPEND external_project_dependencies anakin_shared anakin_saber)

cmake/external/cub.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
if(NOT WITH_GPU)
2+
return()
3+
endif()
4+
5+
include(ExternalProject)
6+
7+
set(CUB_SOURCE_DIR ${THIRD_PARTY_PATH}/cub)
8+
set(CUB_INCLUDE_DIR ${CUB_SOURCE_DIR}/src/extern_cub)
9+
10+
include_directories(${CUB_INCLUDE_DIR})
11+
12+
ExternalProject_Add(
13+
extern_cub
14+
${EXTERNAL_PROJECT_LOG_ARGS}
15+
GIT_REPOSITORY "https://github.com/NVlabs/cub.git"
16+
GIT_TAG "v1.8.0"
17+
PREFIX ${CUB_SOURCE_DIR}
18+
UPDATE_COMMAND ""
19+
CONFIGURE_COMMAND ""
20+
BUILD_COMMAND ""
21+
INSTALL_COMMAND ""
22+
TEST_COMMAND ""
23+
)
24+
25+
if(${CMAKE_VERSION} VERSION_LESS "3.3.0")
26+
set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/cub_dummy.c)
27+
file(WRITE ${dummyfile} "const char *dummy = \"${dummyfile}\";")
28+
add_library(cub STATIC ${dummyfile})
29+
else()
30+
add_library(cub INTERFACE)
31+
endif()
32+
33+
add_dependencies(cub extern_cub)
34+
35+
LIST(APPEND externl_project_dependencies cub)

cmake/external/mkldnn.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SET(MKLDNN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/mkldnn)
2424
SET(MKLDNN_INC_DIR "${MKLDNN_INSTALL_DIR}/include" CACHE PATH "mkldnn include directory." FORCE)
2525

2626
IF(WIN32 OR APPLE)
27-
MESSAGE(WARNING
27+
MESSAGE(WARNING
2828
"Windows or Mac is not supported with MKLDNN in Paddle yet."
2929
"Force WITH_MKLDNN=OFF")
3030
SET(WITH_MKLDNN OFF CACHE STRING "Disable MKLDNN in Windows and MacOS" FORCE)
@@ -57,8 +57,10 @@ ExternalProject_Add(
5757
GIT_TAG "a29d8487a63afca3d5b8c5bbdbb473cf8ccc6e51"
5858
PREFIX ${MKLDNN_SOURCES_DIR}
5959
UPDATE_COMMAND ""
60+
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
61+
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
6062
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR}
61-
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
63+
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
6264
CMAKE_ARGS -DMKLROOT=${MKLML_ROOT}
6365
CMAKE_ARGS -DCMAKE_C_FLAGS=${MKLDNN_CFLAG}
6466
CMAKE_ARGS -DCMAKE_CXX_FLAGS=${MKLDNN_CXXFLAG}

cmake/external/xbyak.cmake

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (c) 2017 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+
set(WITH_XBYAK ON)
16+
if(WIN32 OR APPLE)
17+
SET(WITH_XBYAK OFF CACHE STRING "Disable XBYAK in Windows and MacOS" FORCE)
18+
return()
19+
endif()
20+
21+
include(ExternalProject)
22+
23+
set(XBYAK_PROJECT extern_xbyak)
24+
set(XBYAK_PREFIX_DIR ${THIRD_PARTY_PATH}/xbyak)
25+
set(XBYAK_INSTALL_ROOT ${THIRD_PARTY_PATH}/install/xbyak)
26+
set(XBYAK_INC_DIR ${XBYAK_INSTALL_ROOT}/include)
27+
28+
include_directories(${XBYAK_INC_DIR})
29+
include_directories(${XBYAK_INC_DIR}/xbyak)
30+
31+
add_definitions(-DPADDLE_WITH_XBYAK)
32+
33+
# xbyak options
34+
add_definitions(-DXBYAK64)
35+
add_definitions(-DXBYAK_NO_OP_NAMES)
36+
37+
ExternalProject_Add(
38+
${XBYAK_PROJECT}
39+
${EXTERNAL_PROJECT_LOG_ARGS}
40+
DEPENDS ""
41+
GIT_REPOSITORY "https://github.com/herumi/xbyak.git"
42+
GIT_TAG "v5.661" # Jul 26th
43+
PREFIX ${XBYAK_PREFIX_DIR}
44+
UPDATE_COMMAND ""
45+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${XBYAK_INSTALL_ROOT}
46+
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${XBYAK_INSTALL_ROOT}
47+
)
48+
49+
if (${CMAKE_VERSION} VERSION_LESS "3.3.0")
50+
set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/xbyak_dummy.c)
51+
file(WRITE ${dummyfile} "const char *dummy_xbyak = \"${dummyfile}\";")
52+
add_library(xbyak STATIC ${dummyfile})
53+
else()
54+
add_library(xbyak INTERFACE)
55+
endif()
56+
57+
add_dependencies(xbyak ${XBYAK_PROJECT})
58+
list(APPEND external_project_dependencies xbyak)

cmake/inference_lib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ if (WITH_ANAKIN AND WITH_GPU)
143143
copy(anakin_inference_lib DEPS paddle_inference_api inference_anakin_api
144144
SRCS
145145
${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/libinference_anakin_api* # compiled anakin api
146-
${PADDLE_BINARY_DIR}/third_party/install/anakin/*.tar.gz # anakin release
146+
${ANAKIN_INSTALL_DIR} # anakin release
147147
DSTS ${dst_dir}/inference/anakin ${dst_dir}/inference/anakin)
148148
list(APPEND inference_deps anakin_inference_lib)
149149
endif()

doc/fluid/api/executor.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,3 @@ _switch_scope
3838
.. autofunction:: paddle.fluid.executor._switch_scope
3939
:noindex:
4040

41-
.. _api_fluid_executor_fetch_var:
42-
43-
fetch_var
44-
---------
45-
46-
.. autofunction:: paddle.fluid.executor.fetch_var
47-
:noindex:
48-

doc/fluid/api/fluid.rst

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,6 @@ _switch_scope
106106
.. autofunction:: paddle.fluid._switch_scope
107107
:noindex:
108108

109-
.. _api_fluid_fetch_var:
110-
111-
fetch_var
112-
---------
113-
114-
.. autofunction:: paddle.fluid.fetch_var
115-
:noindex:
116-
117-
.. _api_fluid_Go:
118-
119-
Go
120-
--
121-
122-
.. autoclass:: paddle.fluid.Go
123-
:members:
124-
:noindex:
125109

126110
.. _api_fluid_make_channel:
127111

doc/fluid/design/ir/draft.md renamed to doc/fluid/design/ir/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ graph = PassRegistry::Instance().Get("op_fuse_pass").Apply(std::move(grah));
177177
auto mem_opt_pass = PassRegistry::Instance().Get("memory_optimization_pass");
178178
mem_opt_pass.SetNotOwned<int>("optimize_level", 1);
179179
mem_opt_pass->Apply(std::move(graph));
180-
graph = PassRegistry::Instance().Get("multi_device_pass").Apply(std::move(grah));
181-
graph = PassRegistry::Instance().Get("multi_device_check_pass").Apply(std::move(grah));
180+
graph = PassRegistry::Instance().Get("multi_devices_pass").Apply(std::move(grah));
181+
graph = PassRegistry::Instance().Get("multi_devices_check_pass").Apply(std::move(grah));
182182
Executor exe;
183183
exe.Run(graph);
184184

0 commit comments

Comments
 (0)