Skip to content

Commit e2bb405

Browse files
authored
Merge branch 'develop' into improve-prefetch-on-server
2 parents 9af9eff + b55dc9a commit e2bb405

Some content is hidden

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

78 files changed

+461
-314
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ addons:
3434
- automake
3535
- libtool
3636
- ccache
37-
ssh_known_hosts: 52.76.173.135
37+
ssh_known_hosts: 13.229.163.131
3838
before_install:
3939
- if [[ "$JOB" == "check_style" ]]; then sudo ln -s /usr/bin/clang-format-3.8 /usr/bin/clang-format; fi
4040
# Paddle is using protobuf 3.1 currently. Protobuf 3.2 breaks the compatibility. So we specify the python

doc/fluid/dev/api_doc_std_en.md

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
# API Doc Standard
2+
3+
- [API Doc Structure](#API Doc Structure)
4+
- [Format and Examples](#Format and Examples)
5+
- [Complete Example](#Complete Example)
6+
7+
8+
## API Doc Structure
9+
10+
API Doc should contain the following parts(please write them in order):
11+
12+
- Python API Definition
13+
14+
The definition of API
15+
16+
- Function Description
17+
18+
Description of API's function.
19+
The description includes: meaning, purpose and operation on input of API, reference and corresponding link(if any), formula(if necessary) and explanations of key variables in the formula.
20+
21+
- Args Description
22+
23+
Description of API parameters.
24+
Introduce parameters one by one according to the order in API definition.
25+
The introduction includes: data type, default value(if any), meaning, etc.
26+
27+
- Returns
28+
29+
Introduction of API returned value.
30+
Introduce meaning of returned value, provide correspoding format if necessary.
31+
If returned value is a tuple containing multiple parameters, then introduce parameters one by one in order.
32+
33+
- Raises(if any)
34+
35+
Abnormality, error that may occur, and possible reasons. If there are more than one possible abnormity or error, they should be listed in order.
36+
37+
- Note(if any)
38+
39+
Matters needing attention. If there are more than one matters, they should be listed in order.
40+
41+
- Examples
42+
43+
Examples of how to use API.
44+
45+
46+
## Format and Examples
47+
48+
API documentation must obey reStructuredText format, please refer to [here](http://sphinx-doc-zh.readthedocs.io/en/latest/rest.html).
49+
Format and examples of each part of API documantation are as follows: (take fc for example)
50+
51+
- Python API Definition
52+
53+
- Format
54+
55+
[Python API Definition]
56+
57+
- Example
58+
59+
```
60+
fc(input,
61+
size,
62+
num_flatten_dims=1,
63+
param_attr=None,
64+
bias_attr=None,
65+
act=None,
66+
name=None,
67+
main_program=None,
68+
startup_program=None)
69+
```
70+
71+
- Function Description
72+
73+
- Format
74+
75+
This part contains (please write them in order):
76+
77+
[Function Description]
78+
79+
[Formula]
80+
81+
[Symbols' Descriptions if necessary]
82+
83+
[References if necessary]
84+
85+
- Example
86+
87+
[Function Description]
88+
89+
```
90+
**Fully Connected Layer**
91+
92+
The fully connected layer can take multiple tensors as its inputs. It
93+
creates a variable called weights for each input tensor, which represents
94+
a fully connected weight matrix from each input unit to each output unit.
95+
The fully connected layer multiplies each input tensor with its coresponding
96+
weight to produce an output Tensor. If multiple input tensors are given,
97+
the results of multiple multiplications will be sumed up. If bias_attr is
98+
not None, a bias variable will be created and added to the output. Finally,
99+
if activation is not None, it will be applied to the output as well.
100+
```
101+
102+
[Formula]
103+
104+
```
105+
This process can be formulated as follows:
106+
107+
.. math::
108+
109+
Out = Act({\sum_{i=0}^{N-1}X_iW_i + b})
110+
```
111+
112+
[Symbols' Descriptions if necessary]
113+
114+
```
115+
In the above equation:
116+
117+
* :math:`N`: Number of the input.
118+
* :math:`X_i`: The input tensor.
119+
* :math:`W`: The weights created by this layer.
120+
* :math:`b`: The bias parameter created by this layer (if needed).
121+
* :math:`Act`: The activation function.
122+
* :math:`Out`: The output tensor.
123+
```
124+
125+
[References if necessary]
126+
127+
Since there is no need for reference of fc, we omit them here. Under other circumstances, please provide explicit reference and link, take layer_norm for example:
128+
129+
```
130+
Refer to `Layer Normalization <https://arxiv.org/pdf/1607.06450v1.pdf>`_ for more details.
131+
```
132+
133+
134+
- Args Description
135+
136+
- Format
137+
138+
\[Arg's Name\][(Data Type, Default Value)][Description]
139+
140+
- Example
141+
142+
part of fc parameters are as follows:
143+
144+
```
145+
Args:
146+
input (Variable|list of Variable): The input tensor(s) of this layer, and the dimension of
147+
the input tensor(s) is at least 2.
148+
param_attr (ParamAttr|list of ParamAttr, default None): The parameter attribute for learnable
149+
parameters/weights of this layer.
150+
name (str, default None): The name of this layer.
151+
```
152+
153+
- Returns
154+
155+
- Format
156+
157+
[Name][Shape]
158+
159+
- Example
160+
161+
```
162+
Returns:
163+
A tensor variable storing the transformation result.
164+
```
165+
166+
when returned value contain more than one tuple, please introduce every parameter in order, take dynamic_lstm for example:
167+
168+
```
169+
Returns:
170+
A tuple containing:
171+
The hidden state of LSTM whose shape is (T X D).
172+
The cell state of LSTM whose shape is (T X D).
173+
```
174+
175+
- Raises
176+
177+
- Format
178+
179+
[Exception Type][Condition]
180+
181+
- Example
182+
183+
```
184+
Raises:
185+
ValueError: If the rank of the input is less than 2.
186+
```
187+
188+
- Note
189+
190+
- Format
191+
192+
[Note]
193+
194+
- Example
195+
196+
there is no Note in fc, so we omit this part. If there is any note, please write clearly. If there are more than one notes, please list them in order. Take scaled\_dot\_product\_attention for example:
197+
198+
```
199+
Note:
200+
1. When num_heads > 1, three linear projections are learned respectively
201+
to map input queries, keys and values into queries', keys' and values'.
202+
queries', keys' and values' have the same shapes with queries, keys
203+
and values.
204+
2. When num_heads == 1, scaled_dot_product_attention has no learnable
205+
parameters.
206+
```
207+
208+
- Examples
209+
210+
- Format
211+
212+
\[Python Code Snipper]
213+
214+
- Example
215+
216+
```
217+
Examples:
218+
.. code-block:: python
219+
220+
data = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
221+
fc = fluid.layers.fc(input=data, size=1000, act="tanh")
222+
```
223+
224+
## Complete Example
225+
226+
Complete Example of fc please see [here](src/fc.py)。

paddle/fluid/framework/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ cc_test(init_test SRCS init_test.cc DEPS init)
104104
cc_test(op_kernel_type_test SRCS op_kernel_type_test.cc DEPS place device_context framework_proto)
105105
cc_test(cow_ptr_tests SRCS details/cow_ptr_test.cc)
106106

107-
# cc_test(channel_test SRCS channel_test.cc)
107+
cc_test(channel_test SRCS channel_test.cc)
108108
cc_test(tuple_test SRCS tuple_test.cc )
109109
cc_test(concurrency_test SRCS concurrency_test.cc DEPS go_op channel_close_op channel_create_op
110110
channel_send_op channel_recv_op sum_op select_op elementwise_add_op compare_op

paddle/fluid/framework/channel_impl.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ void ChannelImpl<T>::Send(T *item) {
138138

139139
// If channel is closed, throw exception
140140
if (closed_) {
141-
lock.unlock();
142141
send_return();
142+
lock.unlock();
143143
PADDLE_THROW("Cannot send on closed channel");
144144
}
145145

@@ -152,11 +152,9 @@ void ChannelImpl<T>::Send(T *item) {
152152
if (m != nullptr) {
153153
*(m->data) = std::move(*item);
154154
m->Notify();
155-
lock.unlock();
156155
send_return();
157156
return;
158157
} else {
159-
lock.unlock();
160158
Send(item);
161159
send_return();
162160
return;
@@ -169,8 +167,6 @@ void ChannelImpl<T>::Send(T *item) {
169167
if (buf_.size() < cap_) {
170168
// Copy to buffer
171169
buf_.push_back(std::move(*item));
172-
// Release lock and return true
173-
lock.unlock();
174170
send_return();
175171
return;
176172
}
@@ -181,8 +177,8 @@ void ChannelImpl<T>::Send(T *item) {
181177
sendq.push_back(m);
182178
m->Wait(lock);
183179
if (m->chan_closed) {
184-
lock.unlock();
185180
send_return();
181+
lock.unlock();
186182
PADDLE_THROW("Cannot send on closed channel");
187183
}
188184
send_return();
@@ -195,10 +191,7 @@ bool ChannelImpl<T>::Receive(T *item) {
195191

196192
// If channel is closed and buffer is empty or
197193
// channel is unbuffered
198-
if (closed_ && buf_.empty()) {
199-
lock.unlock();
200-
return recv_return(false);
201-
}
194+
if (closed_ && buf_.empty()) return recv_return(false);
202195

203196
// If there is a sender, directly receive the value we want
204197
// from the sender. In case of a buffered channel, read from
@@ -229,7 +222,6 @@ bool ChannelImpl<T>::Receive(T *item) {
229222
} else
230223
return recv_return(Receive(item));
231224
}
232-
lock.unlock();
233225
return recv_return(true);
234226
}
235227

@@ -238,8 +230,7 @@ bool ChannelImpl<T>::Receive(T *item) {
238230
// Directly read from buffer
239231
*item = std::move(buf_.front());
240232
buf_.pop_front();
241-
// Release lock and return true
242-
lock.unlock();
233+
// return true
243234
return recv_return(true);
244235
}
245236

paddle/fluid/operators/detail/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ if(WITH_DISTRIBUTE)
22
grpc_library(sendrecvop_grpc SRCS bytebuffer_stream.cc sendrecvop_utils.cc grpc_client.cc
33
grpc_server.cc variable_response.cc PROTO send_recv.proto DEPS lod_tensor selected_rows)
44
set(DISTRIBUTE_COMPILE_FLAGS "-Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor")
5-
set_source_files_properties(test_serde.cc grpc_server_test.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
6-
cc_test(serde_test SRCS test_serde.cc variable_response.cc DEPS grpc++_unsecure grpc_unsecure gpr
5+
set_source_files_properties(serde_test.cc grpc_server_test.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
6+
cc_test(serde_test SRCS serde_test.cc variable_response.cc DEPS grpc++_unsecure grpc_unsecure gpr
77
cares zlib protobuf sendrecvop_grpc)
88
cc_test(grpc_server_test SRCS grpc_server_test.cc DEPS sendrecvop_grpc grpc++_unsecure grpc_unsecure gpr cares zlib protobuf)
99
endif()

paddle/fluid/operators/detail/grpc_server.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ class RequestPrefetch final : public RequestBase {
156156

157157
virtual void Process() {
158158
// prefetch process...
159-
::grpc::ByteBuffer relay;
159+
::grpc::ByteBuffer reply;
160160
// TODO(Yancey1989): execute the Block which containers prefetch ops
161161

162162
VLOG(3) << "RequestPrefetch Process in";
163163

164-
responder_.Finish(relay, ::grpc::Status::OK, this);
164+
responder_.Finish(reply, ::grpc::Status::OK, this);
165165
status_ = FINISH;
166166
}
167167

python/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ add_custom_target(paddle_python ALL DEPENDS ${paddle_python_deps})
7373
set(PADDLE_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/)
7474

7575
if (WITH_TESTING)
76+
add_subdirectory(paddle/reader/tests)
77+
add_subdirectory(paddle/dataset/tests)
7678
if(NOT WITH_FLUID_ONLY)
7779
add_subdirectory(paddle/trainer_config_helpers/tests)
7880
if (WITH_SWIG_PY)
7981
# enable v2 API unittest only when paddle swig api is compiled
8082
add_subdirectory(paddle/v2/tests)
81-
add_subdirectory(paddle/v2/reader/tests)
8283
add_subdirectory(paddle/v2/plot/tests)
8384
endif()
8485
endif()

python/paddle/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@
1414
try:
1515
from version import full_version as __version__
1616
from version import commit as __git_commit__
17+
1718
except ImportError:
1819
import sys
1920
sys.stderr.write('''Warning with import paddle: you should not
2021
import paddle from the source directory; please install paddlepaddle*.whl firstly.'''
2122
)
23+
24+
import reader
25+
import dataset
26+
import batch
27+
batch = batch.batch
File renamed without changes.

0 commit comments

Comments
 (0)