From 9c238d2bc27b87a5f946ecf1cdb4e9a7c090f53c Mon Sep 17 00:00:00 2001 From: Difer <707065510@qq.com> Date: Tue, 21 Mar 2023 10:21:01 +0800 Subject: [PATCH] fix softmaxce null point in shape test (#51850) --- paddle/fluid/operators/softmax_with_cross_entropy_op.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/paddle/fluid/operators/softmax_with_cross_entropy_op.cc b/paddle/fluid/operators/softmax_with_cross_entropy_op.cc index df142f3350c..c093078fae0 100644 --- a/paddle/fluid/operators/softmax_with_cross_entropy_op.cc +++ b/paddle/fluid/operators/softmax_with_cross_entropy_op.cc @@ -162,6 +162,13 @@ class SoftmaxWithCrossEntropyOp : public framework::OperatorWithKernel { "R is the rank of Input(Logits).")); axis = phi::funcs::CanonicalAxis(axis, logits_rank); + + PADDLE_ENFORCE_EQ(logits_dims.size(), + labels_dims.size(), + platform::errors::InvalidArgument( + "Input(Logits) and Input(Label) should in " + "same dimensions size.")); + for (int i = 0; i < logits_rank; i++) { if (i != axis) { if (ctx->IsRuntime() || (logits_dims[i] > 0 && labels_dims[i] > 0)) { -- GitLab