提交 cf717fd6 编写于 作者: Y Yamei-Lee 提交者: hong

fix bug in reshape: (#20781)

consider the situation that shape of input can contain more than one -1.
test=develop
上级 1d1552d1
...@@ -186,13 +186,16 @@ class ReshapeOp : public framework::OperatorWithKernel { ...@@ -186,13 +186,16 @@ class ReshapeOp : public framework::OperatorWithKernel {
output_shape[unk_dim_idx] = -1; output_shape[unk_dim_idx] = -1;
} }
} else { } else {
PADDLE_ENFORCE_EQ( if (all_positive) {
capacity, in_size, PADDLE_ENFORCE_EQ(
"ShapeError: The 'shape' in ReshapeOp is invalid. " capacity, in_size,
"The input tensor X'size must be equal to the capacity of 'shape'. " "ShapeError: The 'shape' in ReshapeOp is invalid. "
"But received X's shape = [%s], X's size = %d, 'shape' is [%s], the " "The input tensor X'size must be equal to the capacity of 'shape'. "
"capacity of 'shape' is %d.", "But received X's shape = [%s], X's size = %d, 'shape' is [%s], "
in_dims, in_size, framework::make_ddim(shape), capacity); "the "
"capacity of 'shape' is %d.",
in_dims, in_size, framework::make_ddim(shape), capacity);
}
} }
return framework::make_ddim(output_shape); return framework::make_ddim(output_shape);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册