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 @@ -4732,6 +4732,9 @@ def __check_input(x, y):
4732
4732
4733
4733
if len (y_shape ) > 2 :
4734
4734
for i , dim_x in enumerate (x_shape [:- 2 ]):
4735
+ # don't check neg shape
4736
+ if dim_x < 0 or y_shape [i ] < 0 :
4737
+ continue
4735
4738
if dim_x != y_shape [i ]:
4736
4739
raise ValueError ("Invalid inputs for matmul." )
4737
4740
You can’t perform that action at this time.
0 commit comments