Add check of input in sequence_expand op. (#15466)

* Add check of input in sequence_expand op.
test=develop

* Correct the unittest of sequence_expand op.
test=develop
inference-pre-release-gpu
Yiqun Liu 6 years ago committed by GitHub
parent f4dec5cdee
commit eaad3e4c3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -68,6 +68,11 @@ class SequenceExpandOp : public framework::OperatorWithKernel {
"Level number of Input(X)'s lod could be 0. Otherwise "
"size of Input(X)'s first level lod should be equal to "
"size of Input(Y)'s referred level lod.");
} else {
PADDLE_ENFORCE_EQ(x_dims[0], y_lod[ref_level].size() - 1,
"When Input(X)'s lod is null, the dims[0] of "
"Input(X) should match the "
"size of Input(Y)'s referred level lod.");
}
int64_t out_first_dim = 0;

@ -81,11 +81,10 @@ class TestSequenceExpand(OpTest):
class TestSequenceExpandCase1(TestSequenceExpand):
def set_data(self):
x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float32')
x_lod = [[2, 3]]
y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float32')
y_lod = [[2, 3], [2, 2, 3, 3, 3]]
self.inputs = {'X': x_data, 'Y': (y_data, y_lod)}
self.attrs = {'ref_level': 0}
self.attrs = {'ref_level': 1}
class TestSequenceExpandCase2(TestSequenceExpand):

Loading…
Cancel
Save