@@ -130,12 +130,18 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
130
130
auto * output = ctx.Output <Tensor>(" Output" );
131
131
132
132
PADDLE_ENFORCE_EQ (input->layout (), DataLayout::kMKLDNN ,
133
- " Wrong layout set for Input tensor" );
134
- PADDLE_ENFORCE_NE (input->format (), MKLDNNMemoryFormat::undef,
135
- " Wrong format set for Input tensor" );
133
+ platform::errors::InvalidArgument (
134
+ " The input tensor's layout should be %d, but got %d." ,
135
+ DataLayout::kMKLDNN , input->layout ()));
136
+ PADDLE_ENFORCE_NE (
137
+ input->format (), MKLDNNMemoryFormat::undef,
138
+ platform::errors::InvalidArgument (" Wrong format set for Input tensor" ));
136
139
137
- PADDLE_ENFORCE_EQ (filter->layout (), DataLayout::kMKLDNN ,
138
- " Wrong layout set for Filter tensor" );
140
+ PADDLE_ENFORCE_EQ (
141
+ filter->layout (), DataLayout::kMKLDNN ,
142
+ platform::errors::InvalidArgument (
143
+ " The Filter tensor's layout should be %d, but got %d." ,
144
+ DataLayout::kMKLDNN , filter->layout ()));
139
145
PADDLE_ENFORCE_NE (filter->format (), MKLDNNMemoryFormat::undef,
140
146
" Wrong format set for Filter tensor" );
141
147
@@ -154,8 +160,11 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
154
160
" Filter must be with 4 or 5 dimensions, i.e. OIHW or OIDHW" );
155
161
156
162
if (bias) {
157
- PADDLE_ENFORCE_EQ (bias->layout (), DataLayout::kMKLDNN ,
158
- " Wrong layout set for Bias tensor" );
163
+ PADDLE_ENFORCE_EQ (
164
+ bias->layout (), DataLayout::kMKLDNN ,
165
+ platform::errors::InvalidArgument (
166
+ " The Bias tensor's layout should be %d, but got %d." ,
167
+ DataLayout::kMKLDNN , bias->layout ()));
159
168
PADDLE_ENFORCE_NE (bias->format (), MKLDNNMemoryFormat::undef,
160
169
" Wrong format set for Bias tensor" );
161
170
@@ -371,7 +380,9 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
371
380
auto * output = ctx.Output <Tensor>(" Output" );
372
381
373
382
PADDLE_ENFORCE_EQ (input->layout (), DataLayout::kMKLDNN ,
374
- " Wrong layout set for Input tensor" );
383
+ platform::errors::InvalidArgument (
384
+ " The input tensor's layout should be %d, but got %d." ,
385
+ DataLayout::kMKLDNN , input->layout ()));
375
386
PADDLE_ENFORCE_NE (input->format (), MKLDNNMemoryFormat::undef,
376
387
" Wrong format set for Input tensor" );
377
388
@@ -438,8 +449,11 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
438
449
439
450
auto * filter = ctx.Input <Tensor>(" Filter" );
440
451
441
- PADDLE_ENFORCE_EQ (filter->layout (), DataLayout::kMKLDNN ,
442
- " Wrong layout set for Filter tensor" );
452
+ PADDLE_ENFORCE_EQ (
453
+ filter->layout (), DataLayout::kMKLDNN ,
454
+ platform::errors::InvalidArgument (
455
+ " The filter tensor's layout should be %d, but got %d." ,
456
+ DataLayout::kMKLDNN , filter->layout ()));
443
457
PADDLE_ENFORCE_NE (filter->format (), MKLDNNMemoryFormat::undef,
444
458
" Wrong format set for Filter tensor" );
445
459
@@ -457,8 +471,11 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
457
471
auto * bias = ctx.HasInput (" Bias" ) ? ctx.Input <Tensor>(" Bias" ) : nullptr ;
458
472
459
473
if (bias) {
460
- PADDLE_ENFORCE_EQ (bias->layout (), DataLayout::kMKLDNN ,
461
- " Wrong layout set for Bias tensor" );
474
+ PADDLE_ENFORCE_EQ (
475
+ bias->layout (), DataLayout::kMKLDNN ,
476
+ platform::errors::InvalidArgument (
477
+ " The bias tensor's layout should be %d, but got %d." ,
478
+ DataLayout::kMKLDNN , bias->layout ()));
462
479
PADDLE_ENFORCE_NE (bias->format (), MKLDNNMemoryFormat::undef,
463
480
" Wrong format set for Bias tensor" );
464
481
@@ -743,17 +760,25 @@ class ConvMKLDNNGradOpKernel : public paddle::framework::OpKernel<T> {
743
760
Tensor* filter_grad = ctx.Output <Tensor>(framework::GradVarName (" Filter" ));
744
761
745
762
PADDLE_ENFORCE_EQ (input->layout (), DataLayout::kMKLDNN ,
746
- " Wrong layout set for Input tensor" );
763
+ platform::errors::InvalidArgument (
764
+ " The input tensor's layout should be %d, but got %d." ,
765
+ DataLayout::kMKLDNN , input->layout ()));
747
766
PADDLE_ENFORCE_NE (input->format (), MKLDNNMemoryFormat::undef,
748
767
" Wrong format set for Input tensor" );
749
768
750
- PADDLE_ENFORCE_EQ (filter->layout (), DataLayout::kMKLDNN ,
751
- " Wrong layout set for Filter tensor" );
769
+ PADDLE_ENFORCE_EQ (
770
+ filter->layout (), DataLayout::kMKLDNN ,
771
+ platform::errors::InvalidArgument (
772
+ " The filter tensor's layout should be %d, but got %d." ,
773
+ DataLayout::kMKLDNN , filter->layout ()));
752
774
PADDLE_ENFORCE_NE (filter->format (), MKLDNNMemoryFormat::undef,
753
775
" Wrong format set for Filter tensor" );
754
776
755
- PADDLE_ENFORCE_EQ (output_grad->layout (), DataLayout::kMKLDNN ,
756
- " Wrong layout set for output_grad tensor" );
777
+ PADDLE_ENFORCE_EQ (
778
+ output_grad->layout (), DataLayout::kMKLDNN ,
779
+ platform::errors::InvalidArgument (
780
+ " The output_grad tensor's layout should be %d, but got %d." ,
781
+ DataLayout::kMKLDNN , output_grad->layout ()));
757
782
PADDLE_ENFORCE_NE (output_grad->format (), MKLDNNMemoryFormat::undef,
758
783
" Wrong format set for output_grad tensor" );
759
784
0 commit comments