From f6d390834ec56d421a3a7e377bc4d857b60614f1 Mon Sep 17 00:00:00 2001 From: smallv0221 <33639025+smallv0221@users.noreply.github.com> Date: Sun, 27 Sep 2020 20:10:07 +0800 Subject: [PATCH] Update sequence_conv_op.cc --- .../operators/sequence_ops/sequence_conv_op.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/operators/sequence_ops/sequence_conv_op.cc b/paddle/fluid/operators/sequence_ops/sequence_conv_op.cc index b5ca370088b..85c8e8559a1 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( -- GitLab