@ -50,30 +50,28 @@ void ConvOp::InferShape(framework::InferShapeContext* ctx) const {
const std : : string data_format = ctx - > Attrs ( ) . Get < std : : string > ( " data_format " ) ;
const bool channel_last = ( data_format = = " NHWC " | | data_format = = " NDHWC " ) ;
PADDLE_ENFORCE_EQ ( in_dims . size ( ) = = 4 | | in_dims . size ( ) = = 5 , true ,
" ShapeError: Conv input should be 4-D or 5-D tensor. But "
" received: %u-D Tensor, "
" the shape of Conv input is [%s]" ,
in_dims . size ( ) , in_dims ) ;
PADDLE_ENFORCE_EQ (
in_dims . size ( ) = = 4 | | in_dims . size ( ) = = 5 , true ,
" ShapeError: the input of Op(conv) should be 4-D or 5-D Tensor. But "
" received: %u-D Tensor, the shape of input is [%s]. " ,
in_dims . size ( ) , in_dims ) ;
PADDLE_ENFORCE_EQ (
in_dims . size ( ) , filter_dims . size ( ) ,
" ShapeError: Conv input dimension and filter dimension should be the "
" equal. "
" But received: the shape of Conv input is [%s], input dimension of Conv "
" input is [%d], "
" the shape of filter is [%s], the filter dimension of Conv is [%d] " ,
" ShapeError: the input's dimension size and filter's dimension size of "
" Op(conv) should be equal. But received: the shape of input is [%s], "
" the dimension size of input is [%d], the shape of filter is [%s], "
" the dimension size of filter is [%d]. " ,
in_dims , in_dims . size ( ) , filter_dims , filter_dims . size ( ) ) ;
int in_sub_stride_size = in_dims . size ( ) - strides . size ( ) ;
PADDLE_ENFORCE_EQ ( in_dims . size ( ) - strides . size ( ) = = 2U , true ,
" ShapeError: the dimension of input minus the dimension of "
" stride must be euqal to 2. "
" But received: the dimension of input minus the dimension "
" of stride is [%d], the "
" input dimension of Conv is [%d], the shape of Conv input "
" is [%s], the stride "
" dimension of Conv is [%d] " ,
" ShapeError: the dimension size of input minus the size of "
" Attr(stride) must be euqal to 2 for Op(conv). "
" But received: the dimension size of input minus the size "
" of Attr(stride) is [%d], the "
" input's dimension size is [%d], the shape of input "
" is [%s], the Attr(stride)'s size is [%d]. " ,
in_sub_stride_size , in_dims . size ( ) , in_dims ,
strides . size ( ) ) ;
@ -83,16 +81,19 @@ void ConvOp::InferShape(framework::InferShapeContext* ctx) const {
PADDLE_ENFORCE_EQ (
input_channels , filter_dims [ 1 ] * groups ,
" ShapeError: The number of input channels should be equal to filter "
" channels * groups. But received: the input channels is [%d], the shape "
" of input is [%s], the filter channel is [%d], the shape of filter is "
" [%s], "
" the groups is [%d] " ,
in_dims [ 1 ] , in_dims , filter_dims [ 1 ] , filter_dims , groups ) ;
" channels * groups for Op(conv). But received: the input's channels is "
" [%d], the shape "
" of input is [%s], the filter's channel is [%d], the shape of filter is "
" [%s], the groups is [%d], the data_format is %s. The error may come "
" from wrong data_format setting. " ,
input_channels , in_dims , filter_dims [ 1 ] , filter_dims , groups ,
data_format ) ;
PADDLE_ENFORCE_EQ (
filter_dims [ 0 ] % groups , 0 ,
" ShapeError: The number of output channels should be divided by groups. "
" But received: the output channels is [%d], the shape of filter is [%s] "
" (the first dimension of filter is output channel), the groups is [%d] " ,
" ShapeError: The number of output channels of Op(conv) should be divided "
" by groups. "
" But received: the output channels is [%d], the shape of filter is [%s] "
" (the first dimension of filter is output channel), the groups is [%d]. " ,
filter_dims [ 0 ] , filter_dims , groups ) ;
framework : : DDim in_data_dims ;