File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -46,8 +46,8 @@ class SequenceReshapeKernel : public framework::OpKernel<T> {
46
46
} else {
47
47
auto & out_lod = *out->mutable_lod ();
48
48
out_lod.resize (1 );
49
- out_lod[0 ].clear ( );
50
- out_lod[0 ]. push_back ( 0 ) ;
49
+ out_lod[0 ].resize (seq_num + 1 );
50
+ out_lod[0 ][ 0 ] = 0 ;
51
51
for (int i = 0 ; i < seq_num; ++i) {
52
52
size_t seq_len = in_lod_l0[i + 1 ] - in_lod_l0[i];
53
53
size_t offset = 0 ;
@@ -57,11 +57,10 @@ class SequenceReshapeKernel : public framework::OpKernel<T> {
57
57
" be divided by new_dim with no remainder for each "
58
58
" sequence. The %dth sequence is invalid." ,
59
59
i + 1 );
60
- out_lod[0 ]. push_back ( out_lod[0 ]. back () + offset) ;
60
+ out_lod[0 ][i + 1 ] = out_lod[0 ][i] + offset;
61
61
}
62
62
}
63
63
64
- out->mutable_data <T>(context.GetPlace ());
65
64
framework::Copy (*in, context.GetPlace (), out);
66
65
out->Resize ({static_cast <int64_t >(out->lod ()[0 ].back ()), out_width});
67
66
}
You can’t perform that action at this time.
0 commit comments