提交 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 {
output_shape[unk_dim_idx] = -1;
}
} else {
PADDLE_ENFORCE_EQ(
capacity, in_size,
"ShapeError: The 'shape' in ReshapeOp is invalid. "
"The input tensor X'size must be equal to the capacity of 'shape'. "
"But received X's shape = [%s], X's size = %d, 'shape' is [%s], the "
"capacity of 'shape' is %d.",
in_dims, in_size, framework::make_ddim(shape), capacity);
if (all_positive) {
PADDLE_ENFORCE_EQ(
capacity, in_size,
"ShapeError: The 'shape' in ReshapeOp is invalid. "
"The input tensor X'size must be equal to the capacity of 'shape'. "
"But received X's shape = [%s], X's size = %d, 'shape' is [%s], "
"the "
"capacity of 'shape' is %d.",
in_dims, in_size, framework::make_ddim(shape), capacity);
}
}
return framework::make_ddim(output_shape);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册