Skip to content

Commit 000ba1a

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into port_python3_syntax
2 parents 0c7d6eb + 4b8ae52 commit 000ba1a

File tree

84 files changed

+2439
-649
lines changed

Some content is hidden

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

84 files changed

+2439
-649
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
| tianbingsz | Tian-Bing Xu |
4747
| tpatejko | Tomasz Patejko |
4848
| typhoonzero | Yi Wu |
49+
| velconia | Qi-Yang Min |
4950
| wanghaoshuang | Hao-Shuang Wang |
5051
| wangyang59 | Yang Wang |
5152
| wangzhen-nlp | Zhen Wang |

benchmark/fluid/fluid_benchmark.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ def dist_transpile(trainer_id, args):
8585
trainer_id,
8686
pservers=pserver_endpoints,
8787
trainers=trainers,
88-
sync_mode=not args.async_mode,
89-
slice_var_up=not args.no_split_var)
88+
sync_mode=not args.async_mode)
9089
if training_role == "PSERVER":
9190
pserver_program = t.get_pserver_program(current_endpoint)
9291
pserver_startup_program = t.get_startup_program(current_endpoint,

cmake/external/grpc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ExternalProject_Add(
5050
UPDATE_COMMAND ""
5151
CONFIGURE_COMMAND ""
5252
BUILD_IN_SOURCE 1
53-
PATCH_COMMAND git apply ${PADDLE_SOURCE_DIR}/patches/grpc/fix_too_early_destory.patch
53+
PATCH_COMMAND cp ${PADDLE_SOURCE_DIR}/patches/grpc/grpc_library.h ${GRPC_SOURCES_DIR}/src/extern_grpc/include/grpcpp/impl/codegen/grpc_library.h && cp ${PADDLE_SOURCE_DIR}/patches/grpc/completion_queue.h ${GRPC_SOURCES_DIR}/src/extern_grpc/include/grpcpp/impl/codegen/completion_queue.h
5454
# NOTE(yuyang18):
5555
# Disable -Werror, otherwise the compile will fail in MacOS.
5656
# It seems that we cannot configure that by make command.

cmake/generic.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function(cc_test TARGET_NAME)
263263
COMMAND ${TARGET_NAME} ${cc_test_ARGS}
264264
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
265265
if (${cc_test_SERIAL})
266-
set_property(TEST ${TARGET_NAME} PROPERTY SERIAL 1)
266+
set_property(TEST ${TARGET_NAME} PROPERTY RUN_SERIAL 1)
267267
set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_init_allocated_mem=true)
268268
endif()
269269
endif()
@@ -328,7 +328,7 @@ function(nv_test TARGET_NAME)
328328
add_dependencies(${TARGET_NAME} ${nv_test_DEPS} paddle_gtest_main lod_tensor memory gtest gflags glog)
329329
add_test(${TARGET_NAME} ${TARGET_NAME})
330330
if (nv_test_SERIAL)
331-
set_property(TEST ${TARGET_NAME} PROPERTY SERIAL 1)
331+
set_property(TEST ${TARGET_NAME} PROPERTY RUN_SERIAL 1)
332332
set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_init_allocated_mem=true)
333333
endif()
334334
endif()

cmake/inference_lib.cmake

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,11 @@ if (WITH_ANAKIN AND WITH_GPU)
148148
list(APPEND inference_deps anakin_inference_lib)
149149
endif()
150150

151-
copy(inference_api_lib DEPS paddle_inference_api paddle_inference_api_shared
152-
SRCS ${src_dir}/${module}/paddle_inference_api.h
153-
${src_dir}/${module}/demo_ci
154-
${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/libpaddle_inference_api*
155-
DSTS ${dst_dir}/inference ${dst_dir}/inference ${dst_dir}/inference
156-
)
157-
list(APPEND inference_deps inference_api_lib)
158-
159151
set(module "inference")
160152
copy(inference_lib DEPS ${inference_deps}
161153
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/inference/libpaddle_fluid.*
162-
DSTS ${dst_dir}/${module} ${dst_dir}/${module}
154+
${src_dir}/${module}/api/paddle_inference_api.h ${src_dir}/${module}/api/demo_ci
155+
DSTS ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module}
163156
)
164157

165158
set(module "platform")

doc/fluid/design/ir/draft.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,96 @@ can also contain other things that describe some properties of
6464
the `Graph` or `Graph` nodes. `Attribute` can be passed
6565
across `Pass`. However, it should be used with care.
6666

67+
```cpp
68+
class Graph {
69+
public:
70+
explicit Graph(const ProgramDesc &program);
71+
72+
bool Has(const std::string &attr_name) const;
73+
74+
template <typename AttrType>
75+
AttrType &Get(const std::string &attr_name) const;
76+
77+
template <typename AttrType>
78+
void Set(const std::string &attr_name, AttrType *attr);
79+
const std::unordered_set<ir::Node *> &Nodes() const;
80+
81+
// Create a normal variable with non-null VarDesc.
82+
ir::Node *CreateVarNode(VarDesc *var_desc);
83+
84+
// Create a normal runnable operator with OpDesc.
85+
ir::Node *CreateOpNode(OpDesc *op_desc);
86+
87+
// Create a control dependency var that connects 2 operations. The
88+
// var doesn't hold any data. Other than that, it's no different from
89+
// other var, considering dependency analysis.
90+
ir::Node *CreateControlDepVar();
91+
92+
// A more free style way of creating a graph node. Mostly use for test
93+
// or "copy" from another node. Avoid using it if possible.
94+
ir::Node *CreateEmptyNode(const std::string &name, ir::Node::Type type);
95+
96+
// Clear all node information of the graph and return the ownership of the
97+
// nodes.
98+
std::vector<std::unique_ptr<ir::Node>> ReleaseNodes();
99+
};
100+
```
101+
67102
#### Pass
68103
69104
`Pass` represents a transformation of `Graph`. Its input
70105
is a `Graph` and its output is also a `Graph`. For example,
71106
a `Pass` can simply print out the `Graph`. A `Pass`
72107
can also fuse some `Graph`'s `Node`s.
73108
109+
```cpp
110+
class Pass {
111+
public:
112+
113+
std::unique_ptr<Graph> Apply(std::unique_ptr<Graph> graph) const {
114+
// Some correctness check.
115+
auto new_graph = ApplyImpl(std::move(graph));
116+
// Some correctness check.
117+
return new_graph;
118+
}
119+
120+
// Get a reference to the attributed previously set.
121+
template <typename AttrType>
122+
AttrType &Get(const std::string &attr_name) const;
123+
124+
// Set a pointer to the attribute. Pass takes ownership of the attribute.
125+
template <typename AttrType>
126+
void Set(const std::string &attr_name, AttrType *attr) ;
127+
128+
// Set a pointer to the attribute. Pass doesn't take ownership. Caller
129+
// should delete the attribute.
130+
template <typename AttrType>
131+
void SetNotOwned(const std::string &attr_name, AttrType *attr);
132+
133+
protected:
134+
virtual std::unique_ptr<Graph> ApplyImpl(std::unique_ptr<Graph> graph) const = 0;
135+
};
136+
137+
// In my_pass.cc
138+
class MyPass : public Pass {
139+
protected:
140+
std::unique_ptr<Graph> ApplyImpl(std::unique_ptr<Graph> graph) const override {
141+
// do something.
142+
return graph;
143+
}
144+
}
145+
REGISTER_PASS(my_pass, MyPass)
146+
.RequirePassAttr("places")
147+
.RequireGraphAttr("dep_vars");
148+
149+
150+
// To use the pass.
151+
auto my_pass = ir::PassRegistry::Instance().Get("my_pass");
152+
graph = my_pass->Apply(std::move(graph));
153+
// Note: to force link my_pass.cc, in the code:
154+
USE_PASS(my_pass);
155+
```
156+
74157
#### Optimize
75158

76159
`Optimize` contains a series of `Pass` with defined order.
@@ -86,4 +169,17 @@ maintaining the original modeling logic.
86169
* Graph is transformed from raw model logic to a
87170
form that is efficient to execute.
88171

89-
Program->ProgramToGraph->Graph->Pass1->Graph->Pass2->Graph->Pass3->Graph->Executor
172+
```
173+
// Program->ProgramToGraph->Graph->Pass1->Graph->Pass2->Graph->Pass3->Graph->Executor
174+
auto graph = Graph(program);
175+
graph = PassRegistry::Instance().Get("op_fuse_pass").Apply(std::move(grah));
176+
// For more complex Pass, Optimize Process can provide Pass attributes.
177+
auto mem_opt_pass = PassRegistry::Instance().Get("memory_optimization_pass");
178+
mem_opt_pass.SetNotOwned<int>("optimize_level", 1);
179+
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));
182+
Executor exe;
183+
exe.Run(graph);
184+
185+
```

paddle/fluid/framework/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ cc_test(ddim_test SRCS ddim_test.cc DEPS ddim)
88
nv_test(dim_test SRCS dim_test.cu DEPS ddim)
99
cc_library(data_type SRCS data_type.cc DEPS framework_proto ddim device_context)
1010
if(WITH_GPU)
11-
nv_library(tensor SRCS tensor.cc tensor_util.cu DEPS place memory data_type)
11+
nv_library(tensor SRCS tensor.cc tensor_util.cu DEPS place memory data_type device_context)
1212
else()
13-
cc_library(tensor SRCS tensor.cc tensor_util.cc DEPS place memory data_type)
13+
cc_library(tensor SRCS tensor.cc tensor_util.cc DEPS place memory data_type device_context)
1414
endif()
1515

1616
cc_test(tensor_test SRCS tensor_test.cc DEPS tensor)
@@ -99,7 +99,7 @@ else()
9999
endif()
100100

101101

102-
cc_library(parallel_executor SRCS parallel_executor.cc DEPS ssa_graph_builder_factory threaded_ssa_graph_executor scope_buffered_ssa_graph_executor graph)
102+
cc_library(parallel_executor SRCS parallel_executor.cc DEPS threaded_ssa_graph_executor scope_buffered_ssa_graph_executor graph graph_viz_pass multi_devices_graph_builder ssa_graph_printer ssa_graph_checker)
103103

104104
cc_library(prune SRCS prune.cc DEPS framework_proto)
105105
cc_test(prune_test SRCS prune_test.cc DEPS op_info prune recurrent_op device_context)
@@ -110,7 +110,7 @@ cc_test(selected_rows_test SRCS selected_rows_test.cc DEPS selected_rows)
110110

111111
cc_test(op_kernel_type_test SRCS op_kernel_type_test.cc DEPS place device_context framework_proto)
112112
cc_test(cow_ptr_tests SRCS details/cow_ptr_test.cc)
113-
113+
114114
# cc_test(channel_test SRCS channel_test.cc)
115115
cc_test(tuple_test SRCS tuple_test.cc )
116116

paddle/fluid/framework/details/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ cc_library(fuse_vars_op_handle SRCS fuse_vars_op_handle.cc DEPS op_handle_base s
3131
cc_library(multi_devices_graph_builder SRCS multi_devices_graph_builder.cc DEPS ssa_graph_builder computation_op_handle
3232
scale_loss_grad_op_handle rpc_op_handle all_reduce_op_handle reduce_op_handle broadcast_op_handle data_balance_op_handle)
3333

34-
35-
cc_library(ssa_graph_builder_factory SRCS ssa_graph_builder_factory.cc DEPS multi_devices_graph_builder ssa_graph_printer ssa_graph_checker)
36-
3734
cc_library(ssa_graph_executor SRCS ssa_graph_executor.cc DEPS graph framework_proto)
3835
cc_library(threaded_ssa_graph_executor SRCS threaded_ssa_graph_executor.cc DEPS fetch_op_handle ssa_graph_executor scope
3936
simple_threadpool device_context)

0 commit comments

Comments
 (0)