diff --git a/paddle/fluid/operators/batch_norm_op.cc b/paddle/fluid/operators/batch_norm_op.cc index edf34cc1c455282e1d0fd05c026e98fa80705fee..0cc3e1f2b8350acb693ad7ba4f4dab270068723b 100644 --- a/paddle/fluid/operators/batch_norm_op.cc +++ b/paddle/fluid/operators/batch_norm_op.cc @@ -68,6 +68,9 @@ void BatchNormOp::InferShape(framework::InferShapeContext *ctx) const { auto scale_dim = ctx->GetInputDim("Scale"); auto bias_dim = ctx->GetInputDim("Bias"); + PADDLE_ENFORCE_EQ(scale_dim.size(), 1UL); + PADDLE_ENFORCE_EQ(scale_dim.size(), 1UL); + bool check = true; if ((!ctx->IsRuntime()) && (framework::product(scale_dim) <= 0 || framework::product(bias_dim) <= 0)) { @@ -75,9 +78,7 @@ void BatchNormOp::InferShape(framework::InferShapeContext *ctx) const { } if (check) { - PADDLE_ENFORCE_EQ(scale_dim.size(), 1UL); PADDLE_ENFORCE_EQ(scale_dim[0], C); - PADDLE_ENFORCE_EQ(scale_dim.size(), 1UL); PADDLE_ENFORCE_EQ(scale_dim[0], C); } ctx->SetOutputDim("Y", x_dims);