From f0985cecb93c7e9b5c36e5372f9c7a40d24dda04 Mon Sep 17 00:00:00 2001 From: superjomn Date: Tue, 16 Apr 2019 12:07:24 +0800 Subject: [PATCH] fix logical op infershape test=develop --- paddle/fluid/operators/controlflow/logical_op.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/controlflow/logical_op.cc b/paddle/fluid/operators/controlflow/logical_op.cc index 2e7f3edd5..6e37bf1cb 100644 --- a/paddle/fluid/operators/controlflow/logical_op.cc +++ b/paddle/fluid/operators/controlflow/logical_op.cc @@ -71,8 +71,14 @@ class BinaryLogicalOpInferShape : public framework::InferShapeBase { "Input(Y) of %s operator must not be null", comment.type); auto dim_x = context->GetInputDim("X"); auto dim_y = context->GetInputDim("Y"); - PADDLE_ENFORCE_EQ(framework::product(dim_x), framework::product(dim_y), - "The number of elements in X and Y should be same"); + + int product_x = framework::product(dim_x); + int product_y = framework::product(dim_y); + bool check = ctx->IsRuntime() && product_x >= 0 && product_y >= 0; + if (check) { + PADDLE_ENFORCE_EQ(framework::product(dim_x), framework::product(dim_y), + "The number of elements in X and Y should be same"); + } context->SetOutputDim("Out", context->GetInputDim("X")); context->ShareLoD("X", "Out"); -- GitLab