From 4035bd2b79441eaf6f7c7c8f13d650eed3acbac5 Mon Sep 17 00:00:00 2001 From: wenbin Date: Tue, 7 Dec 2021 10:55:28 +0800 Subject: [PATCH] don't exit if requested_size < size (#37880) don't exit if requested_size < size --- paddle/fluid/framework/tensor.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/paddle/fluid/framework/tensor.cc b/paddle/fluid/framework/tensor.cc index 063ede6ffbf..cbbc020989d 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!= */ -- GitLab