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

fix the reduce bug test=develop (#20102)

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