未验证 提交 e3c68bde 编写于 作者: T Tao Luo 提交者: GitHub

stronger the error message of tensor's mutable_data (#19303)

* stronger the error message of tensor's mutable_data

test=develop

* update error message

test=develop
上级 6a163231
...@@ -40,7 +40,9 @@ void* Tensor::mutable_data(platform::Place place, proto::VarType::Type type, ...@@ -40,7 +40,9 @@ void* Tensor::mutable_data(platform::Place place, proto::VarType::Type type,
PADDLE_ENFORCE_GE(numel(), 0, PADDLE_ENFORCE_GE(numel(), 0,
"When calling this method, the Tensor's numel must be " "When calling this method, the Tensor's numel must be "
"equal or larger than zero. " "equal or larger than zero. "
"Please check Tensor::Resize has been called first."); "Please check Tensor::dims, or Tensor::Resize has been "
"called first. The Tensor's shape is [",
dims(), "] now");
size_t size = numel() * SizeOfType(type); size_t size = numel() * SizeOfType(type);
if (requested_size) { if (requested_size) {
PADDLE_ENFORCE_GE(requested_size, size); PADDLE_ENFORCE_GE(requested_size, size);
...@@ -57,8 +59,8 @@ void* Tensor::mutable_data(platform::Place place, proto::VarType::Type type, ...@@ -57,8 +59,8 @@ void* Tensor::mutable_data(platform::Place place, proto::VarType::Type type,
} }
void* Tensor::mutable_data(platform::Place place, size_t requested_size) { void* Tensor::mutable_data(platform::Place place, size_t requested_size) {
PADDLE_ENFORCE(this->holder_ != nullptr, PADDLE_ENFORCE_NOT_NULL(
"Cannot invoke mutable data if current hold nothing."); this->holder_, "Cannot invoke mutable data if current hold nothing.");
return mutable_data(place, type_, requested_size); return mutable_data(place, type_, requested_size);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册