diff --git a/paddle/fluid/framework/tensor.cc b/paddle/fluid/framework/tensor.cc index 565b7d9d16cb4d048c57b841857390a3dea3ed7a..f8bf9c5dc782ccaecf9c1f31be8070d441d0cace 100644 --- a/paddle/fluid/framework/tensor.cc +++ b/paddle/fluid/framework/tensor.cc @@ -40,7 +40,9 @@ void* Tensor::mutable_data(platform::Place place, proto::VarType::Type type, PADDLE_ENFORCE_GE(numel(), 0, "When calling this method, the Tensor's numel must be " "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); if (requested_size) { PADDLE_ENFORCE_GE(requested_size, size); @@ -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) { - PADDLE_ENFORCE(this->holder_ != nullptr, - "Cannot invoke mutable data if current hold nothing."); + PADDLE_ENFORCE_NOT_NULL( + this->holder_, "Cannot invoke mutable data if current hold nothing."); return mutable_data(place, type_, requested_size); }