From 5309b081f6a483b2d4e2a76e05a28ed37a62a30d Mon Sep 17 00:00:00 2001 From: phlrain Date: Tue, 16 Apr 2019 02:52:13 +0000 Subject: [PATCH] simple code; test=develop --- paddle/fluid/operators/softmax_with_cross_entropy_op.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/operators/softmax_with_cross_entropy_op.cc b/paddle/fluid/operators/softmax_with_cross_entropy_op.cc index 2f4702ed7..7c024e50d 100644 --- a/paddle/fluid/operators/softmax_with_cross_entropy_op.cc +++ b/paddle/fluid/operators/softmax_with_cross_entropy_op.cc @@ -111,11 +111,8 @@ class SoftmaxWithCrossEntropyOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( rank, labels_dims.size(), "Input(logits) and Input(Label) shall have the same rank."); - bool check = true; - if ((!ctx->IsRuntime()) && (framework::product(logits_dims) <= 0 || - framework::product(labels_dims) <= 0)) { - check = false; - } + bool check = ctx->IsRuntime() || (framework::product(logits_dims) > 0 && + framework::product(labels_dims) > 0); if (check) { PADDLE_ENFORCE_EQ(framework::slice_ddim(logits_dims, 0, rank - 1), framework::slice_ddim(labels_dims, 0, rank - 1), -- GitLab