diff --git a/paddle/fluid/operators/sequence_ops/sequence_conv_op.cc b/paddle/fluid/operators/sequence_ops/sequence_conv_op.cc index b5ca370088bc6d74226fdb82a3bc080eb4da26d4..85c8e8559a1a33a0e36a5f2bab842f26b2219473 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_conv_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_conv_op.cc @@ -68,12 +68,15 @@ class SequenceConvOp : public framework::OperatorWithKernel { int down_pad = std::max(0, context_start + context_length - 1); int total_pad = up_pad + down_pad; int input_width = static_cast(in_dims[1]); + bool start_equals_zero = context_start == 0; + bool length_equals_one = context_length == 1; + bool start_length = start_equals_zero && length_equals_one; - if (context_start == 0 && context_length == 1) { - PADDLE_THROW(platform::errors::InvalidArgument( - "If context_start is 0 and context_length is 1, paddingTrainable " - "should be false.")); - } + PADDLE_ENFORCE_EQ( + start_length, false, + platform::errors::InvalidArgument( + "If context_start is 0 and context_length is 1, paddingTrainable " + "should be false.")); PADDLE_ENFORCE_EQ( padding_dim.size(), 2, platform::errors::InvalidArgument(