Skip to content

Commit fda1a78

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into fix_api_reference_docs
2 parents 9397a2e + e6654c1 commit fda1a78

File tree

155 files changed

+5241
-1640
lines changed

Some content is hidden

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

155 files changed

+5241
-1640
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
| jczaja | Jacek Czaja |
2323
| JiayiFeng | Jia-Yi Feng |
2424
| kbinias | Krzysztof Binias |
25+
| kexinzhao | Ke-Xin Zhao |
2526
| kuke | Yi-Bing Liu |
2627
| lcy-seso | Ying Cao |
2728
| lipeng-unisound | Peng Li |

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ option(EIGEN_USE_THREADS "Compile with multi-threaded Eigen" OFF)
6161
option(WITH_ARM_FP16 "Use half precision support on armv8.2-a cpu" OFF)
6262
option(WITH_FAST_BUNDLE_TEST "Bundle tests that can be run in a single process together to reduce launch overhead" OFF)
6363
option(WITH_CONTRIB "Compile the third-party contributation" OFF)
64+
option(WITH_ANAKIN "Compile with Anakin library" OFF)
6465
option(WITH_GRPC "Use grpc as the default rpc framework" ${WITH_DISTRIBUTE})
6566

6667
# CMAKE_BUILD_TYPE
@@ -193,7 +194,10 @@ set(EXTERNAL_LIBS
193194
if(WITH_GPU)
194195
include(cuda)
195196
include(tensorrt)
196-
endif(WITH_GPU)
197+
include(external/anakin)
198+
else()
199+
set(WITH_ANAKIN OFF CACHE STRING "Anakin is valid only when GPU is set." FORCE)
200+
endif()
197201

198202
if(WITH_AMD_GPU)
199203
find_package(HIP)

benchmark/fluid/models/machine_translation.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,6 @@ def simple_attention(encoder_vec, encoder_proj, decoder_state):
173173
return avg_cost, feeding_list
174174

175175

176-
def to_lodtensor(data, place):
177-
seq_lens = [len(seq) for seq in data]
178-
cur_len = 0
179-
lod = [cur_len]
180-
for l in seq_lens:
181-
cur_len += l
182-
lod.append(cur_len)
183-
flattened_data = np.concatenate(data, axis=0).astype("int64")
184-
flattened_data = flattened_data.reshape([len(flattened_data), 1])
185-
lod_t = core.LoDTensor()
186-
lod_t.set(flattened_data, place)
187-
lod_t.set_lod([lod])
188-
return lod_t, lod[-1]
189-
190-
191176
def lodtensor_to_ndarray(lod_tensor):
192177
dims = lod_tensor.get_dims()
193178
ndarray = np.zeros(shape=dims).astype('float32')

benchmark/fluid/models/stacked_dynamic_lstm.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,3 @@ def gate_common(
125125
batch_size=args.batch_size)
126126

127127
return loss, inference_program, adam, train_reader, test_reader, batch_acc
128-
129-
130-
def to_lodtensor(data, place):
131-
seq_lens = [len(seq) for seq in data]
132-
cur_len = 0
133-
lod = [cur_len]
134-
for l in seq_lens:
135-
cur_len += l
136-
lod.append(cur_len)
137-
flattened_data = numpy.concatenate(data, axis=0).astype("int64")
138-
flattened_data = flattened_data.reshape([len(flattened_data), 1])
139-
res = fluid.LoDTensor()
140-
res.set(flattened_data, place)
141-
res.set_lod([lod])
142-
return res

cmake/external/anakin.cmake

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
if (NOT WITH_ANAKIN)
2+
return()
3+
endif()
4+
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")
9+
10+
set(ANAKIN_COMPILE_EXTRA_FLAGS -Wno-error=unused-variable -Wno-error=format-extra-args -Wno-error=comment -Wno-error=format -Wno-error=switch -Wno-error=return-type -Wno-error=non-virtual-dtor -Wno-reorder -Wno-error=cpp)
11+
12+
set(ANAKIN_LIBRARY_URL "https://github.com/pangge/Anakin/releases/download/3.0/anakin_release_simple.tar.gz")
13+
14+
# A helper function used in Anakin, currently, to use it, one need to recursively include
15+
# nearly all the header files.
16+
function(fetch_include_recursively root_dir)
17+
if (IS_DIRECTORY ${root_dir})
18+
include_directories(${root_dir})
19+
endif()
20+
21+
file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*)
22+
foreach(sub ${ALL_SUB})
23+
if (IS_DIRECTORY ${root_dir}/${sub})
24+
fetch_include_recursively(${root_dir}/${sub})
25+
endif()
26+
endforeach()
27+
endfunction()
28+
29+
# download library
30+
message(STATUS "Download Anakin library from ${ANAKIN_LIBRARY_URL}")
31+
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
32+
execute_process(COMMAND bash -c "rm -rf ${ANAKIN_INSTALL_DIR}/*")
33+
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget -q ${ANAKIN_LIBRARY_URL}")
34+
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
35+
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin_release_simple.tar.gz")
36+
37+
if (WITH_ANAKIN)
38+
message(STATUS "Anakin for inference is enabled")
39+
message(STATUS "Anakin is set INCLUDE:${ANAKIN_INCLUDE} LIBRARY:${ANAKIN_LIBRARY}")
40+
fetch_include_recursively(${ANAKIN_INCLUDE})
41+
link_directories(${ANAKIN_LIBRARY})
42+
endif()

cmake/external/openblas.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ IF(NOT ${CBLAS_FOUND})
2929
"${CBLAS_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}openblas${CMAKE_STATIC_LIBRARY_SUFFIX}"
3030
CACHE FILEPATH "openblas library." FORCE)
3131

32+
ADD_DEFINITIONS(-DPADDLE_USE_OPENBLAS)
33+
3234
SET(OPENBLAS_CC "${CMAKE_C_COMPILER} -Wno-unused-but-set-variable -Wno-unused-variable")
3335
SET(OPENBLAS_COMMIT "v0.2.20")
3436

cmake/inference_lib.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function(copy TARGET)
3939
message(FATAL_ERROR "${TARGET} source numbers are not equal to destination numbers")
4040
endif()
4141
math(EXPR len "${copy_lib_SRCS_len} - 1")
42-
42+
4343
add_custom_target(${TARGET} DEPENDS ${copy_lib_DEPS})
4444
foreach(index RANGE ${len})
4545
list(GET copy_lib_SRCS ${index} src)
@@ -155,6 +155,15 @@ copy(inference_lib DEPS paddle_fluid_shared paddle_fluid
155155
DSTS ${dst_dir}/${module} ${dst_dir}/${module}
156156
)
157157

158+
if(WITH_CONTRIB)
159+
set(contrib_dst_dir "${FLUID_INSTALL_DIR}/contrib/inference")
160+
copy(contrib_inference_lib DEPS paddle_inference_api
161+
SRCS ${PADDLE_SOURCE_DIR}/paddle/contrib/inference/paddle_inference_api.h
162+
${PADDLE_BINARY_DIR}/paddle/contrib/inference/libpaddle_inference_api.*
163+
DSTS ${contrib_dst_dir} ${contrib_dst_dir}
164+
)
165+
endif()
166+
158167
set(module "platform")
159168
copy(platform_lib DEPS profiler_py_proto
160169
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/dynload/*.h ${src_dir}/${module}/details/*.h

doc/fluid/api/gen_doc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
python gen_doc.py layers --submodules control_flow device io nn ops tensor detection learning_rate_scheduler > layers.rst
2+
python gen_doc.py layers --submodules control_flow device io nn ops tensor detection learning_rate_scheduler metric > layers.rst
33

44
for module in data_feeder clip metrics executor initializer io nets optimizer param_attr profiler regularizer
55
do

doc/fluid/api/initializer.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ Xavier
3333
:members:
3434
:noindex:
3535

36+
Bilinear
37+
--------
38+
39+
.. autoclass:: paddle.fluid.initializer.Bilinear
40+
:members:
41+
:noindex:
42+
3643
force_init_on_cpu
3744
-----------------
3845

@@ -73,3 +80,10 @@ XavierInitializer
7380
:members:
7481
:noindex:
7582

83+
BilinearInitializer
84+
-------------------
85+
86+
.. autoclass:: paddle.fluid.initializer.BilinearInitializer
87+
:members:
88+
:noindex:
89+

doc/fluid/api/io.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,39 @@ get_inference_program
5959
.. autofunction:: paddle.fluid.io.get_inference_program
6060
:noindex:
6161

62+
save_checkpoint
63+
---------------
64+
65+
.. autofunction:: paddle.fluid.io.save_checkpoint
66+
:noindex:
67+
68+
load_checkpoint
69+
---------------
70+
71+
.. autofunction:: paddle.fluid.io.load_checkpoint
72+
:noindex:
73+
74+
clean_checkpoint
75+
----------------
76+
77+
.. autofunction:: paddle.fluid.io.clean_checkpoint
78+
:noindex:
79+
80+
load_persist_vars_without_grad
81+
------------------------------
82+
83+
.. autofunction:: paddle.fluid.io.load_persist_vars_without_grad
84+
:noindex:
85+
86+
save_persist_vars_without_grad
87+
------------------------------
88+
89+
.. autofunction:: paddle.fluid.io.save_persist_vars_without_grad
90+
:noindex:
91+
92+
get_latest_checkpoint_serial
93+
----------------------------
94+
95+
.. autofunction:: paddle.fluid.io.get_latest_checkpoint_serial
96+
:noindex:
97+

0 commit comments

Comments
 (0)