Skip to content

Commit 7e91da4

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into add_cudnn_pool3d
2 parents 7c2fd61 + 08bc08d commit 7e91da4

File tree

98 files changed

+2783
-1290
lines changed

Some content is hidden

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

98 files changed

+2783
-1290
lines changed

benchmark/paddle/image/run_mkldnn.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
set -e
22

33
function train() {
4-
unset OMP_NUM_THREADS MKL_NUM_THREADS
5-
export OMP_DYNAMIC="FALSE"
6-
export KMP_AFFINITY="granularity=fine,compact,0,0"
4+
unset OMP_NUM_THREADS MKL_NUM_THREADS OMP_DYNAMIC KMP_AFFINITY
75
topology=$1
86
layer_num=$2
97
bs=$3
@@ -14,8 +12,6 @@ function train() {
1412
elif [ $4 == "False" ]; then
1513
thread=`nproc`
1614
# each trainer_count use only 1 core to avoid conflict
17-
export OMP_NUM_THREADS=1
18-
export MKL_NUM_THREADS=1
1915
log="logs/${topology}-${layer_num}-${thread}mklml-${bs}.log"
2016
else
2117
echo "Wrong input $3, use True or False."

cmake/external/openblas.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ IF(NOT ${CBLAS_FOUND})
9898
ENDIF()
9999
INSTALL(CODE "execute_process(
100100
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CBLAS_INSTALL_DIR}/lib
101-
destination ${CMAKE_INSTALL_PREFIX}/${TMP_INSTALL_DIR}
101+
${CMAKE_INSTALL_PREFIX}/${TMP_INSTALL_DIR}
102102
)"
103103
)
104104
INSTALL(CODE "MESSAGE(STATUS \"Installing: \"

doc/design/ops/images/2_level_rnn.dot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
digraph G {
22

3-
rnn [label="1-th level RNN" shape=box]
3+
rnn [label="1st level RNN" shape=box]
44

55
subgraph cluster0 {
66
label = "time step 0"
77

88
sent0 [label="sentence"]
99
sent1 [label="sentence"]
1010

11-
rnn1 [label="2-th level RNN" shape=box]
11+
rnn1 [label="2nd level RNN" shape=box]
1212

1313
sent0 -> rnn1
1414
sent1 -> rnn1
@@ -20,7 +20,7 @@ digraph G {
2020
sent2 [label="sentence"]
2121
sent3 [label="sentence"]
2222

23-
rnn2 [label="2-th level RNN" shape=box]
23+
rnn2 [label="2nd level RNN" shape=box]
2424

2525
sent2 -> rnn2
2626
sent3 -> rnn2
@@ -32,7 +32,7 @@ digraph G {
3232
sent4 [label="sentence"]
3333
sent5 [label="sentence"]
3434

35-
rnn3 [label="2-th level RNN" shape=box]
35+
rnn3 [label="2nd level RNN" shape=box]
3636

3737
sent4 -> rnn3
3838
sent5 -> rnn3

doc/design/ops/rnn.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
# RNNOp design
22

3-
This document is about an RNN operator which requires that instances in a mini-batch have the same length. We will have a more flexible RNN operator.
3+
This document describes the RNN (Recurrent Neural Network) operator and how it is implemented in PaddlePaddle. The RNN op requires that all instances in a mini-batch have the same length. We will have a more flexible dynamic RNN operator in the future.
44

55
## RNN Algorithm Implementation
66

7-
<p aligh="center">
7+
<p align="center">
88
<img src="./images/rnn.jpg"/>
99
</p>
1010

1111
The above diagram shows an RNN unrolled into a full network.
1212

13-
There are several important concepts:
13+
There are several important concepts here:
1414

15-
- *step-net*: the sub-graph to run at each step,
16-
- *memory*, $h_t$, the state of the current step,
17-
- *ex-memory*, $h_{t-1}$, the state of the previous step,
18-
- *initial memory value*, the ex-memory of the first step.
15+
- *step-net*: the sub-graph that runs at each step.
16+
- *memory*, $h_t$, the state of the current step.
17+
- *ex-memory*, $h_{t-1}$, the state of the previous step.
18+
- *initial memory value*, the memory of the first (initial) step.
1919

2020
### Step-scope
2121

22-
There could be local variables defined in step-nets. PaddlePaddle runtime realizes these variables in *step-scopes* -- scopes created for each step.
22+
There could be local variables defined in each step-net. PaddlePaddle runtime realizes these variables in *step-scopes* which are created for each step.
2323

24-
<p aligh="center">
24+
<p align="center">
2525
<img src="./images/rnn.png"/><br/>
26-
Figure 2 the RNN's data flow
26+
Figure 2 illustrates the RNN's data flow
2727
</p>
2828

29-
Please be aware that all steps run the same step-net. Each step
29+
Please be aware that every step runs the same step-net. Each step does the following:
3030

31-
1. creates the step-scope,
32-
2. realizes local variables, including step-outputs, in the step-scope, and
33-
3. runs the step-net, which could use these variables.
31+
1. Creates the step-scope.
32+
2. Initializes the local variables including step-outputs, in the step-scope.
33+
3. Runs the step-net, which uses the above mentioned variables.
3434

35-
The RNN operator will compose its output from step outputs in step scopes.
35+
The RNN operator will compose its output from step outputs in each of the step scopes.
3636

3737
### Memory and Ex-memory
3838

39-
Let's give more details about memory and ex-memory via a simply example:
39+
Let's give more details about memory and ex-memory using a simple example:
4040

4141
$$
4242
h_t = U h_{t-1} + W x_t
4343
$$,
4444
45-
where $h_t$ and $h_{t-1}$ are the memory and ex-memory of step $t$'s respectively.
45+
where $h_t$ and $h_{t-1}$ are the memory and ex-memory (previous memory) of step $t$ respectively.
4646
47-
In the implementation, we can make an ex-memory variable either "refers to" the memory variable of the previous step,
48-
or copy the value of the previous memory value to the current ex-memory variable.
47+
In the implementation, we can make an ex-memory variable either "refer to" the memory variable of the previous step,
48+
or copy the memory value of the previous step to the current ex-memory variable.
4949
5050
### Usage in Python
5151
5252
For more information on Block, please refer to the [design doc](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/block.md).
5353
54-
We can define an RNN's step-net using Block:
54+
We can define an RNN's step-net using a Block:
5555
5656
```python
5757
import paddle as pd
5858
59-
X = some_op() # x is some operator's output, and is a LoDTensor
59+
X = some_op() # x is some operator's output and is a LoDTensor
6060
a = some_op()
6161
6262
# declare parameters
@@ -68,7 +68,7 @@ with rnn.stepnet():
6868
x = rnn.add_input(X)
6969
# declare a memory (rnn's step)
7070
h = rnn.add_memory(init=a)
71-
# h.pre_state() means previous memory of rnn
71+
# h.pre_state(), the previous memory of rnn
7272
new_state = pd.add_two( pd.matmul(W, x) + pd.matmul(U, h.pre_state()))
7373
# update current memory
7474
h.update(new_state)
@@ -80,19 +80,19 @@ out = rnn()
8080
8181
Python API functions in above example:
8282
83-
- `rnn.add_input` indicates the parameter is a variable that will be segmented into step-inputs.
84-
- `rnn.add_memory` creates a variable used as the memory.
85-
- `rnn.add_outputs` mark the variables that will be concatenated across steps into the RNN output.
83+
- `rnn.add_input`: indicates that the parameter is a variable that will be segmented into step-inputs.
84+
- `rnn.add_memory`: creates a variable used as the memory.
85+
- `rnn.add_outputs`: marks the variables that will be concatenated across steps into the RNN output.
8686
8787
### Nested RNN and LoDTensor
8888
8989
An RNN whose step-net includes other RNN operators is known as an *nested RNN*.
9090
91-
For example, we could have a 2-level RNN, where the top level corresponds to paragraphs, and the lower level corresponds to sentences.
91+
For example, we could have a 2-level RNN, where the top level corresponds to paragraphs, and the lower level corresponds to sentences. Each step of the higher level RNN also receives an input from the corresponding step of the lower level, and additionally the output from the previous time step at the same level.
9292
93-
The following figure illustrates the feeding of text into the lower level, one sentence each step, and the feeding of step outputs to the top level. The final top level output is about the whole text.
93+
The following figure illustrates feeding in text into the lower level, one sentence at a step, and the feeding in step outputs to the top level. The final top level output is about the whole text.
9494
95-
<p aligh="center">
95+
<p align="center">
9696
<img src="./images/2_level_rnn.png"/>
9797
</p>
9898
@@ -110,7 +110,7 @@ a = some_op()
110110
111111
# chapter_data is a set of 128-dim word vectors
112112
# the first level of LoD is sentence
113-
# the second level of LoD is chapter
113+
# the second level of LoD is a chapter
114114
chapter_data = pd.Variable(shape=[None, 128], type=pd.lod_tensor, level=2)
115115
116116
def lower_level_rnn(paragraph):
@@ -138,14 +138,14 @@ with top_level_rnn.stepnet():
138138
pd.matmul(W0, paragraph_data) + pd.matmul(U0, h.pre_state()))
139139
top_level_rnn.add_outputs(h)
140140
141-
# just output the last step
141+
# output the last step
142142
chapter_out = top_level_rnn(output_all_steps=False)
143143
```
144144
145-
in above example, the construction of the `top_level_rnn` calls `lower_level_rnn`. The input is a LoD Tensor. The top level RNN segments input text data into paragraphs, and the lower level RNN segments each paragraph into sentences.
145+
In the above example, the construction of the `top_level_rnn` calls `lower_level_rnn`. The input is an LoD Tensor. The top level RNN segments input text data into paragraphs, and the lower level RNN segments each paragraph into sentences.
146146
147-
By default, the `RNNOp` will concatenate the outputs from all the time steps,
148-
if the `output_all_steps` set to False, it will only output the final time step.
147+
By default, the `RNNOp` will concatenate the outputs from all the time steps.
148+
If the `output_all_steps` is set to False, it will only output the final time step.
149149
150150
151151
<p align="center">

0 commit comments

Comments
 (0)