File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,21 @@ class SumOp : public framework::OperatorWithKernel {
65
65
if (framework::product (in_dim) == 0 ) {
66
66
in_dim = x_dim;
67
67
} else {
68
- PADDLE_ENFORCE_EQ (in_dim, x_dim, " Input tensors must have same shape" );
68
+ if (ctx->IsRuntime ()) {
69
+ PADDLE_ENFORCE_EQ (in_dim, x_dim,
70
+ " Input tensors must have same shape" );
71
+ } else {
72
+ PADDLE_ENFORCE_EQ (in_dim.size (), x_dim.size (),
73
+ " Input tensors must have same shape size" );
74
+ // if in_dim or x_dim has -1, not check equal
75
+ for (int i = 0 ; i < x_dim.size (); ++i) {
76
+ if (x_dim[i] == -1 || in_dim[i] == -1 ) {
77
+ continue ;
78
+ }
79
+ PADDLE_ENFORCE_EQ (in_dim[i], x_dim[i],
80
+ " Input tensors must have same shape if not -1" );
81
+ }
82
+ }
69
83
}
70
84
}
71
85
ctx->SetOutputDim (" Out" , in_dim);
You can’t perform that action at this time.
0 commit comments