File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -32,10 +32,14 @@ class BprLossOp : public framework::OperatorWithKernel {
32
32
int rank = x_dims.size ();
33
33
PADDLE_ENFORCE_EQ (rank, label_dims.size (),
34
34
" Input(X) and Input(Label) shall have the same rank." );
35
- PADDLE_ENFORCE_EQ (framework::slice_ddim (x_dims, 0 , rank - 1 ),
36
- framework::slice_ddim (label_dims, 0 , rank - 1 ),
37
- " Input(X) and Input(Label) shall have the same shape "
38
- " except the last dimension." );
35
+
36
+ if (ctx->IsRuntime () || (framework::product (x_dims) > 0 &&
37
+ framework::product (label_dims) > 0 )) {
38
+ PADDLE_ENFORCE_EQ (framework::slice_ddim (x_dims, 0 , rank - 1 ),
39
+ framework::slice_ddim (label_dims, 0 , rank - 1 ),
40
+ " Input(X) and Input(Label) shall have the same shape "
41
+ " except the last dimension." );
42
+ }
39
43
40
44
auto y_dims = x_dims;
41
45
y_dims[rank - 1 ] = 1 ;
You can’t perform that action at this time.
0 commit comments