未验证 提交 4d36c1c7 编写于 作者: W wangchaochaohu 提交者: GitHub

fix the reduce bug test=develop (#20102) (#20557)

上级 b0f39ad3
......@@ -171,6 +171,12 @@ class ReduceOp : public framework::OperatorWithKernel {
"dimensions = %d, X's shape = [%s].",
x_rank, x_dims);
auto dims = ctx->Attrs().Get<std::vector<int>>("dim");
PADDLE_ENFORCE_GT(
dims.size(), 0,
"ShapeError: The input dim dimensions of Reduce "
"shoud be greater than 0. But received the dim dimesions of Reduce "
" = %d",
dims.size());
for (size_t i = 0; i < dims.size(); ++i) {
PADDLE_ENFORCE_LT(dims[i], x_rank,
......
......@@ -138,8 +138,7 @@ class SimpleRNNCell(fluid.Layer):
type='reduce_sum',
inputs={'X': softmax_out},
outputs={'Out': reduce_out},
attrs={'dim': [],
'keep_dim': False,
attrs={'keep_dim': False,
'reduce_all': True})
return reduce_out, hidden
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册