diff --git a/paddle/fluid/operators/maxout_op.cc b/paddle/fluid/operators/maxout_op.cc index 85323b69449594a2045bacfabff8ec0749c56252..33b555a0c75c025850fafd19698aa6c70da1cf64 100644 --- a/paddle/fluid/operators/maxout_op.cc +++ b/paddle/fluid/operators/maxout_op.cc @@ -82,6 +82,14 @@ class MaxOutOp : public framework::OperatorWithKernel { // check groups > 1 PADDLE_ENFORCE_GT(groups, 1, "Attr(groups) of Op(maxout) should be larger than 1."); + PADDLE_ENFORCE_EQ( + in_x_dims[axis] % groups, 0, + "ValueError: The number of input channels for Op(maxout) " + "should be divisible by Attr(groups). But received: the " + "input's channels is [%d], the shape of input is [%s], " + "the Attr(groups) is [%d], the Attr(axis) is [%d]. The " + "error may come from wrong Attr(groups) or Attr(axis) setting.", + in_x_dims[axis], in_x_dims, groups, axis); std::vector output_shape( {in_x_dims[0], in_x_dims[1], in_x_dims[2], in_x_dims[3]}); output_shape[axis] = in_x_dims[axis] / groups;