|
|
@ -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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|