File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
python/paddle/fluid/layers Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -290,8 +290,10 @@ class MatMulOp : public framework::OperatorWithKernel {
290
290
context->Attrs ().Get <bool >(" transpose_Y" ));
291
291
292
292
PADDLE_ENFORCE_EQ (mat_dim_x.width_ , mat_dim_y.height_ );
293
- PADDLE_ENFORCE (mat_dim_x.batch_size_ == mat_dim_y.batch_size_ ||
294
- mat_dim_x.batch_size_ == 0 || mat_dim_y.batch_size_ == 0 );
293
+ if (context->IsRuntime ()) {
294
+ PADDLE_ENFORCE (mat_dim_x.batch_size_ == mat_dim_y.batch_size_ ||
295
+ mat_dim_x.batch_size_ == 0 || mat_dim_y.batch_size_ == 0 );
296
+ }
295
297
std::vector<int64_t > dim_out;
296
298
if (mat_dim_x.batch_size_ != 0 ) {
297
299
dim_out = framework::vectorize (dim_x);
Original file line number Diff line number Diff line change @@ -4901,6 +4901,9 @@ def __check_input(x, y):
4901
4901
4902
4902
if len (y_shape ) > 2 and len (x_shape ) > 2 :
4903
4903
for i , dim_x in enumerate (x_shape [:- 2 ]):
4904
+ # don't check neg shape
4905
+ if dim_x < 0 or y_shape [i ] < 0 :
4906
+ continue
4904
4907
if dim_x != y_shape [i ]:
4905
4908
raise ValueError ("Invalid inputs for matmul. x(%s), y(%s)" %
4906
4909
(x .shape , y .shape ))
You can’t perform that action at this time.
0 commit comments