From e0285eae645105872f7f72ab41b22cda6c1a0c34 Mon Sep 17 00:00:00 2001 From: Zhang Ting Date: Mon, 11 Nov 2019 20:13:01 +0800 Subject: [PATCH] add check for input channels and Attr(groups), test=develop (#21095) --- paddle/fluid/operators/maxout_op.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/paddle/fluid/operators/maxout_op.cc b/paddle/fluid/operators/maxout_op.cc index 85323b6944..33b555a0c7 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; -- GitLab