Skip to content

Commit 24ba5ee

Browse files
authored
merge develop conflict (#31122)
1 parent edacb62 commit 24ba5ee

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

paddle/fluid/operators/softmax_with_cross_entropy_op.cu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ struct HardLabelSoftmaxWithCrossEntropyFunctor {
268268
int64_t idx_remain = idx % remain;
269269
// labels, loss view as [n, remain]
270270
int64_t idx_lbl = idx_n * remain + idx_remain;
271+
PADDLE_ENFORCE(labels_[idx_lbl] >= 0 && labels_[idx_lbl] < d_,
272+
"The value of label[%ld] expected >= 0 and < %ld,"
273+
"but got %ld. Please check input value.",
274+
idx_lbl, d_, labels_[idx_lbl]);
271275
// It also would ignore labels not in range(class_num).
272276
if (idx_axis != labels_[idx_lbl]) {
273277
log_softmax_[idx] = exp_on_device(log_softmax_[idx]);

0 commit comments

Comments
 (0)