Skip to content

Commit f20c887

Browse files
phlrainliuwei1031
authored andcommitted
Merge pull request #15717 from phlrain/fix_leak
Fix lstm possible leak test=release/1.3
1 parent 34446e6 commit f20c887

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

paddle/fluid/operators/lstm_op.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ class LSTMGradKernel : public framework::OpKernel<T> {
311311
lstm_grad.prev_state_grad = c0_g ? ordered_c0_g.data<T>() : nullptr;
312312
}
313313

314+
// lstm_value.output_value not used in bp, set to nullptr
315+
// lstm_grad.state_active_grad not used in bp, set to nullptr
316+
lstm_value.output_value = nullptr;
317+
lstm_grad.state_active_grad = nullptr;
314318
int cur_batch_size = bend - bstart;
315319
math::LstmUnitGradFunctor<DeviceContext, T>::compute(
316320
device_ctx, lstm_value, lstm_grad, frame_size, cur_batch_size,

paddle/fluid/operators/lstmp_op.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ class LSTMPGradKernel : public framework::OpKernel<T> {
405405
}
406406

407407
int cur_batch_size = bend - bstart;
408+
// lstmp_value.output_value not used in bp, set to null
409+
// lstmp_grad.state_active_grad not used in bp, set to null
410+
lstmp_value.output_value = nullptr;
411+
lstmp_grad.state_active_grad = nullptr;
412+
408413
math::LstmUnitGradFunctor<DeviceContext, T>::compute(
409414
device_ctx, lstmp_value, lstmp_grad, frame_size, cur_batch_size,
410415
gate_act, cell_act, cand_act);

0 commit comments

Comments
 (0)