diff --git a/paddle/fluid/framework/tensor.cc b/paddle/fluid/framework/tensor.cc index 063ede6ffbf3197ec8fad51d25a5ac56ad8a00ad..cbbc020989d1e97c779ffca0b2048b973e554289 100644 --- a/paddle/fluid/framework/tensor.cc +++ b/paddle/fluid/framework/tensor.cc @@ -62,14 +62,7 @@ void* Tensor::mutable_data(const platform::Place& place, "The Tensor's shape is [", dims(), "] now")); size_t size = numel() * SizeOfType(type); - if (requested_size) { - PADDLE_ENFORCE_GE( - requested_size, size, - platform::errors::InvalidArgument( - "The requested memory size is less than the memory size of Tensor. " - "But received requested memory size is %d, " - "memory size of Tensor is %d.", - requested_size, size)); + if (requested_size && (requested_size > size)) { size = requested_size; } /* some versions of boost::variant don't have operator!= */