未验证 提交 9219495c 编写于 作者: C chentianyu03 提交者: GitHub

[Phi]fix pad3d infermeta bug (#41020)

* fix pad3d infermeta bug

* add check for construct ScalarArray
上级 2089b485
...@@ -397,6 +397,14 @@ phi::InferMetaContext BuildInferMetaContext(InferShapeContext* ctx, ...@@ -397,6 +397,14 @@ phi::InferMetaContext BuildInferMetaContext(InferShapeContext* ctx,
for (size_t i = 0; i < tensor_dims.size(); ++i) { for (size_t i = 0; i < tensor_dims.size(); ++i) {
num_ele *= tensor_dims[i]; num_ele *= tensor_dims[i];
} }
if (num_ele <= 0) {
PADDLE_THROW(platform::errors::Unimplemented(
"Invalid number for construct phi::ScalarArray, expected "
"number > 0, but actually is %d. ",
num_ele));
}
} else { } else {
num_ele = vars.size(); num_ele = vars.size();
} }
......
...@@ -1116,6 +1116,7 @@ void Pad3dInferMeta(const MetaTensor& x, ...@@ -1116,6 +1116,7 @@ void Pad3dInferMeta(const MetaTensor& x,
out_dims[1] = x_dim[1]; out_dims[1] = x_dim[1];
out_dims[2] = x_dim[2]; out_dims[2] = x_dim[2];
out_dims[3] = x_dim[3]; out_dims[3] = x_dim[3];
out_dims[4] = x_dim[4];
} else { } else {
auto paddings = paddings_scalar_array.GetData(); auto paddings = paddings_scalar_array.GetData();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册