Skip to content

Commit 2c22552

Browse files
committed
Fix some comments and adapt test_machine_translation.py.
1 parent 2f2c5f5 commit 2c22552

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

paddle/fluid/operators/sequence_expand_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ and input(Y)
145145
[0, 3, 6, 6, 8]]
146146
ref_level: 0
147147
then we get 1-level LoDTensor
148-
Out.lod = [[0, 2, 5, 8]]
148+
Out.lod = [[0, 1, 2, 5, 8]]
149149
Out.data = [[a], [a], [b], [c], [d], [b], [c], [d]]
150150
Out.dims = [8, 1]
151151
@@ -157,7 +157,7 @@ Given a common Tensor input(X)
157157
and input(Y)
158158
Y.lod = [[0, 2, 3, 6]]
159159
ref_level: -1
160-
then we a common Tensor
160+
then we get a common Tensor
161161
Out.data = [[a], [a], [b], [c], [c], [c]]
162162
Out.dims = [6, 1]
163163

paddle/fluid/operators/sequence_expand_op.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ class SequenceExpandKernel : public framework::OpKernel<T> {
3737
int ref_level = context.Attr<int>("ref_level");
3838
auto& x_lod = x->lod();
3939
auto& y_lod = y->lod();
40-
PADDLE_ENFORCE_GT(y_lod.size(), 0,
41-
"Level number of `Y`'s lod should be greater than 0.");
42-
PADDLE_ENFORCE(
43-
ref_level == -1 || (ref_level >= 0 && ref_level < y_lod.size()),
44-
"Invlid `ref_level`, which should be either equal to -1 "
45-
"or in [0, %d)",
46-
y_lod.size());
4740

4841
if (ref_level == -1) ref_level = y_lod.size() - 1;
4942

python/paddle/fluid/tests/book/test_machine_translation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ def decoder_decode(context, is_sparse):
118118
is_sparse=is_sparse)
119119

120120
# use rnn unit to update rnn
121-
current_state = pd.fc(input=[pre_ids_emb, pre_state_expanded],
121+
current_state = pd.fc(input=[pre_state_expanded, pre_ids_emb],
122122
size=decoder_size,
123123
act='tanh')
124-
124+
current_state_with_lod = pd.lod_reset(x=current_state, y=pre_score)
125125
# use score to do beam search
126-
current_score = pd.fc(input=current_state,
126+
current_score = pd.fc(input=current_state_with_lod,
127127
size=target_dict_dim,
128128
act='softmax')
129129
topk_scores, topk_indices = pd.topk(current_score, k=50)

0 commit comments

Comments
 (0)