Skip to content

Commit fd3e32e

Browse files
committed
Merge develop
2 parents 0718113 + 6b4d290 commit fd3e32e

21 files changed

+746
-126
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ option(WITH_ANAKIN "Compile with Anakin library" OFF)
6969
option(WITH_GRPC "Use grpc as the default rpc framework" ${WITH_DISTRIBUTE})
7070
option(WITH_BRPC_RDMA "Use brpc rdma as the rpc protocal" OFF)
7171
option(WITH_INFERENCE "Compile fluid inference library" ON)
72+
option(WITH_INFERENCE_API_TEST "Test fluid inference high-level api interface" OFF)
7273
option(WITH_SYSTEM_BLAS "Use system blas library" OFF)
7374
option(PY_VERSION "Compile PaddlePaddle with python3 support" ${PY_VERSION})
7475

cmake/tensorrt.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ find_library(TENSORRT_LIBRARY NAMES libnvinfer.so libnvinfer.a
1818
if(TENSORRT_INCLUDE_DIR AND TENSORRT_LIBRARY)
1919
if(WITH_DSO)
2020
set(TENSORRT_FOUND ON)
21-
endif(WITH DSO)
21+
endif(WITH_DSO)
2222
else()
2323
set(TENSORRT_FOUND OFF)
2424
endif()

doc/fluid/dev/versioning_en.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Versioning (Work In Progress)
2+
3+
4+
PaddlePaddle framework follows Semantic Versioning 2.0 (semver).
5+
Each release has version of the following format: MAJOR.MINOR.PATCH
6+
(e.g. 1.2.0). Some key points:
7+
8+
9+
* Major version number change can result in backward-incompatible changes. Codes working in old version don’t necessarily work in the new version. In addition, data, such as program model and checkpointed parameters, generated by the previous major version might not work in the new version. Tools will be attempted to be built to help the release migration.
10+
11+
* Minor version number change always maintain backward compatibility. It normally contains compatible improvements and bug fixes.
12+
13+
* Patch number change is for bug fixes.
14+
15+
* Violation of the policy are considered as bugs and should be fixed.
16+
17+
### What is Covered
18+
19+
* All public documented Python APIs, excluding those live in the contrib namespace.
20+
21+
### What is Not Covered
22+
23+
* If an API’s implementation has bugs, we reserve the rights to fix the bugs and change the behavior.
24+
25+
* The Python APIs in contrib namespace.
26+
27+
* The Python function and classes that start with ‘_’.
28+
29+
* The offline tools.
30+
31+
* The data generated by the framework, such as serialized Program model file and checkpointed variables, are subject to different versioning scheme described below.
32+
33+
* C++ Inference APIs. (To be covered)
34+
35+
36+
## Data
37+
38+
39+
Data refers to the artifacts generated by the framework. Here, we specifically mean model Program file and the checkpointed variables.
40+
41+
42+
43+
* Backward Compatibility: User sometimes generates Data at PaddlePaddle version 1.1 and expects it to be consumed by PaddlePaddle version 1.2.
44+
This can happen when an new online system wants to serve an old model trained previously.
45+
46+
47+
48+
* Forward Compatibility: User sometimes generates Data at PaddlePaddle version 1.2 and expects it to be consumed by PaddlePaddle version 1.1.
49+
The can happen when an new successful research model want to be served by an old online system that is not frequently upgraded.
50+
51+
52+
53+
### Versioning
54+
55+
Data version. Data is assigned an integer version number. Version is increased when incompatible change is introduced.
56+
57+
PaddlePaddle framework has an interval of Data version that it supports. PadlePaddle framework within the same major version (semver) cannot drop support of lower version of Data. Hence, a minor version change cannot drop support of Data version.
58+
59+
60+
For example, For PaddlePaddle version 1.1, it supports Program version 3 to 5. Later, Program version is increased from 5 to 6 due to addition of an attribute. As a result PaddlePaddle version 1.1 won’t be able to consume it. PaddlePaddle 1.2 should support Program version 3 to 6. PaddlePaddle can only drop support for Program version 3 until PaddlePaddle version 2.0.
61+
62+
63+
64+
### Known Issues
65+
66+
Currently, forward compatibility for new Data version is best-effort.

paddle/fluid/API.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ paddle.fluid.layers.beam_search_decode ArgSpec(args=['ids', 'scores', 'beam_size
116116
paddle.fluid.layers.conv2d_transpose ArgSpec(args=['input', 'num_filters', 'output_size', 'filter_size', 'padding', 'stride', 'dilation', 'groups', 'param_attr', 'bias_attr', 'use_cudnn', 'act', 'name'], varargs=None, keywords=None, defaults=(None, None, 0, 1, 1, None, None, None, True, None, None))
117117
paddle.fluid.layers.conv3d_transpose ArgSpec(args=['input', 'num_filters', 'output_size', 'filter_size', 'padding', 'stride', 'dilation', 'groups', 'param_attr', 'bias_attr', 'use_cudnn', 'act', 'name'], varargs=None, keywords=None, defaults=(None, None, 0, 1, 1, None, None, None, True, None, None))
118118
paddle.fluid.layers.sequence_expand ArgSpec(args=['x', 'y', 'ref_level', 'name'], varargs=None, keywords=None, defaults=(-1, None))
119+
paddle.fluid.layers.sequence_expand_as ArgSpec(args=['x', 'y', 'name'], varargs=None, keywords=None, defaults=(None,))
119120
paddle.fluid.layers.sequence_pad ArgSpec(args=['x', 'pad_value', 'maxlen'], varargs=None, keywords=None, defaults=(None,))
120121
paddle.fluid.layers.lstm_unit ArgSpec(args=['x_t', 'hidden_t_prev', 'cell_t_prev', 'forget_bias', 'param_attr', 'bias_attr', 'name'], varargs=None, keywords=None, defaults=(0.0, None, None, None))
121122
paddle.fluid.layers.reduce_sum ArgSpec(args=['input', 'dim', 'keep_dim', 'name'], varargs=None, keywords=None, defaults=(None, False, None))

paddle/fluid/framework/details/multi_devices_graph_pass.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ static const char kLocalScopes[] = "local_scopes";
127127
static const char kStrategy[] = "strategy";
128128

129129
void MultiDevSSAGraphBuilder::Init() const {
130+
all_vars_.clear();
131+
balance_vars_.clear();
132+
130133
loss_var_name_ = Get<const std::string>(kLossVarName);
131134
places_ = Get<const std::vector<platform::Place>>(kPlaces);
132135
local_scopes_ = Get<const std::vector<Scope *>>(kLocalScopes);

paddle/fluid/framework/details/multi_devices_graph_pass.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ class MultiDevSSAGraphBuilder : public ir::Pass {
4040
size_t device_id) const;
4141
void Init() const;
4242

43-
private:
44-
mutable std::string loss_var_name_;
45-
mutable std::vector<platform::Place> places_;
46-
mutable std::vector<Scope *> local_scopes_;
47-
mutable std::unordered_set<std::string> grad_names_;
48-
4943
#ifdef PADDLE_WITH_CUDA
5044
mutable platform::NCCLContextMap *nccl_ctxs_;
5145
#endif
@@ -95,13 +89,17 @@ class MultiDevSSAGraphBuilder : public ir::Pass {
9589
size_t GetAppropriateDeviceID(
9690
const std::vector<std::string> &var_names) const;
9791

98-
private:
92+
void SetCommunicationContext(OpHandleBase *op_handle,
93+
const platform::Place &p) const;
94+
95+
mutable std::string loss_var_name_;
96+
mutable std::vector<platform::Place> places_;
97+
mutable std::vector<Scope *> local_scopes_;
98+
mutable std::unordered_set<std::string> grad_names_;
99+
99100
mutable BuildStrategy strategy_;
100101
mutable std::unordered_map<std::string, VarDesc *> all_vars_;
101102
mutable std::vector<int64_t> balance_vars_;
102-
103-
void SetCommunicationContext(OpHandleBase *op_handle,
104-
const platform::Place &p) const;
105103
};
106104
} // namespace details
107105
} // namespace framework

paddle/fluid/framework/parallel_executor.cc

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -233,30 +233,9 @@ ParallelExecutor::ParallelExecutor(
233233

234234
void ParallelExecutor::BCastParamsToDevices(
235235
const std::unordered_set<std::string> &vars) const {
236-
// the initializing bcast, all vars would be bcast from device(0),
237-
// otherwise
238-
// bcast from the specified device.
239-
bool initializing = member_->executor_ ? false : true;
236+
// the initializing bcast, all vars would be bcast from device(0).
240237
for (auto &var : vars) {
241-
int var_dev_id = -1;
242-
if (member_->executor_) {
243-
auto &sharded_var_device =
244-
member_->executor_->Graph().Get<details::ShardedVarDevice>(
245-
details::kShardedVarDevice);
246-
if (sharded_var_device.find(var) != sharded_var_device.end()) {
247-
var_dev_id = sharded_var_device.at(var);
248-
}
249-
}
250-
251-
if (!initializing && var_dev_id == -1) continue;
252-
253-
framework::Variable *main_var = nullptr;
254-
if (initializing) {
255-
main_var = member_->local_scopes_[0]->FindVar(var);
256-
} else {
257-
main_var = member_->local_scopes_[var_dev_id]->FindVar(var);
258-
}
259-
238+
framework::Variable *main_var = member_->local_scopes_[0]->FindVar(var);
260239
if (main_var == nullptr || !main_var->IsType<LoDTensor>()) {
261240
continue;
262241
}
@@ -272,8 +251,7 @@ void ParallelExecutor::BCastParamsToDevices(
272251
auto place = member_->places_[i];
273252
void *buffer;
274253

275-
if ((initializing && i == 0) ||
276-
(!initializing && static_cast<int>(i) == var_dev_id)) {
254+
if (i == 0) {
277255
buffer = const_cast<void *>(main_tensor.data<void>());
278256
} else {
279257
auto local_scope = member_->local_scopes_[i];
@@ -290,29 +268,18 @@ void ParallelExecutor::BCastParamsToDevices(
290268
platform::NCCLGroupGuard guard;
291269
for (size_t i = 0; i < member_->places_.size(); ++i) {
292270
auto &nccl_ctx = member_->nccl_ctxs_->at(member_->places_[i]);
293-
if (initializing) {
294-
platform::dynload::ncclBcast(buffers[i], numel, data_type, 0,
295-
nccl_ctx.comm_, nccl_ctx.stream());
296-
} else {
297-
if (var_dev_id >= 0) {
298-
platform::dynload::ncclBcast(buffers[i], numel, data_type,
299-
var_dev_id, nccl_ctx.comm_,
300-
nccl_ctx.stream());
301-
}
302-
}
271+
platform::dynload::ncclBcast(buffers[i], numel, data_type, 0,
272+
nccl_ctx.comm_, nccl_ctx.stream());
303273
}
304274
member_->nccl_ctxs_->WaitAll();
305275
}
306-
307276
#else
308277
PADDLE_THROW("Not compiled with CUDA");
309278
#endif
310279
} else {
311280
platform::CPUPlace cpu;
312281
for (size_t i = 0; i < member_->places_.size(); ++i) {
313-
if ((initializing && i == 0) ||
314-
(!initializing && static_cast<int>(i) == var_dev_id))
315-
continue;
282+
if (i == 0) continue;
316283

317284
auto local_scope = member_->local_scopes_[i];
318285
auto *t = local_scope->Var(var)->GetMutable<LoDTensor>();

paddle/fluid/framework/parallel_executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class ParallelExecutor {
7272
void Run(const std::vector<std::string> &fetch_tensors,
7373
const std::string &fetched_var_name);
7474

75+
private:
7576
void BCastParamsToDevices(const std::unordered_set<std::string> &vars) const;
7677

77-
private:
7878
ParallelExecutorPrivate *member_;
7979

8080
#ifdef PADDLE_WITH_CUDA

paddle/fluid/inference/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
1717
# paddle_fluid_origin exclude inference api interface
1818
cc_library(paddle_fluid_origin DEPS ${fluid_modules} paddle_fluid_api)
1919

20-
#if(APPLE)
21-
add_subdirectory(api)
22-
#endif()
20+
add_subdirectory(api)
2321

2422
# Create static library
2523
cc_library(paddle_fluid DEPS ${fluid_modules} paddle_fluid_api paddle_inference_api analysis_predictor)
@@ -57,5 +55,7 @@ endif()
5755
if(WITH_TESTING)
5856
# tests/book depends the models that generated by python/paddle/fluid/tests/book
5957
add_subdirectory(tests/book)
60-
add_subdirectory(tests/api)
58+
if(WITH_INFERENCE_API_TEST)
59+
add_subdirectory(tests/api)
60+
endif()
6161
endif()

paddle/fluid/inference/api/CMakeLists.txt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,4 @@ if (WITH_ANAKIN AND WITH_MKL) # only needed in CI
6969
endfunction()
7070
anakin_target(inference_anakin_api)
7171
anakin_target(inference_anakin_api_shared)
72-
if (WITH_TESTING)
73-
# TODO(luotao): ANAKIN_MODLE_URL etc will move to demo ci later.
74-
set(INFERENCE_URL "http://paddle-inference-dist.bj.bcebos.com")
75-
set(ANAKIN_RNN_MODLE_URL "${INFERENCE_URL}/anakin_test%2Fditu_rnn.anakin2.model.bin")
76-
set(ANAKIN_RNN_DATA_URL "${INFERENCE_URL}/anakin_test%2Fditu_rnn_data.txt")
77-
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_SOURCE_DIR}")
78-
execute_process(COMMAND bash -c "cd ${ANAKIN_SOURCE_DIR}; wget -q --no-check-certificate ${ANAKIN_RNN_MODLE_URL} -N")
79-
execute_process(COMMAND bash -c "cd ${ANAKIN_SOURCE_DIR}; wget -q --no-check-certificate ${ANAKIN_RNN_DATA_URL} -N")
80-
if(WITH_GPU)
81-
set(anakin_test_extra_deps dynload_cuda)
82-
set(ANAKIN_MODLE_URL "${INFERENCE_URL}/mobilenet_v2.anakin.bin")
83-
execute_process(COMMAND bash -c "cd ${ANAKIN_SOURCE_DIR}; wget -q --no-check-certificate ${ANAKIN_MODLE_URL} -N")
84-
cc_test(api_anakin_engine_tester SRCS api_anakin_engine_tester.cc
85-
ARGS --model=${ANAKIN_SOURCE_DIR}/mobilenet_v2.anakin.bin
86-
DEPS inference_anakin_api_shared ${anakin_test_extra_deps} SERIAL)
87-
endif()
88-
cc_test(api_anakin_engine_rnn_tester SRCS api_anakin_engine_rnn_tester.cc
89-
ARGS --model=${ANAKIN_SOURCE_DIR}/anakin_test%2Fditu_rnn.anakin2.model.bin
90-
--datapath=${ANAKIN_SOURCE_DIR}/anakin_test%2Fditu_rnn_data.txt
91-
DEPS inference_anakin_api_shared ${anakin_test_extra_deps} SERIAL)
92-
endif(WITH_TESTING)
9372
endif()

0 commit comments

Comments
 (0)