diff --git a/paddle/fluid/operators/controlflow/conditional_block_op.cc b/paddle/fluid/operators/controlflow/conditional_block_op.cc index f64f3f3935955350a340b6fa56e2abea414379d8..4aa400afbf810f5c6c5861a95c01c91b0ff61ab6 100644 --- a/paddle/fluid/operators/controlflow/conditional_block_op.cc +++ b/paddle/fluid/operators/controlflow/conditional_block_op.cc @@ -255,6 +255,9 @@ class ConditionalBlockGradOp : public ConditionalOp { const auto &input_tensors = input_var->Get(); auto *outside_tensors = outside_var->GetMutable(); + if (outside_tensors->size() == 0U) { + outside_tensors->resize(input_tensors.size()); + } PADDLE_ENFORCE_EQ(input_tensors.size(), outside_tensors->size(), platform::errors::InvalidArgument(