未验证 提交 0c3657ad 编写于 作者: Z zyfncg 提交者: GitHub

fix the bug of SetAllocationForOutputTenosr (#39174)

上级 1efeec1d
......@@ -231,9 +231,14 @@ void DenseTensor::ResetHolder(const std::shared_ptr<pten::Allocation>& holder) {
"Only the offset is supported to zero when the holder is reset."));
if (holder_) {
// TODO(zyfncg): The change of static_cast<> in check will recover back
// when SetAllocationForOutputTenosr is deleted.
// Now the numel() may return -1, and will cast to a very large number when
// compare with a data with unsigned long type, this will make checking
// failed, so it's a temporary solution to deal with this problem.
PADDLE_ENFORCE_LE(
numel() * SizeOf(dtype()) + meta_.offset,
holder->size(),
numel() * static_cast<int64_t>(SizeOf(dtype())),
static_cast<int64_t>(holder->size()),
paddle::platform::errors::InvalidArgument(
"The size of Holder is not enough to store the Tensor."));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册