diff --git a/paddle/framework/tensor_impl.h b/paddle/framework/tensor_impl.h index f75cc31b3994840d9a54a6d45b18ad0e305c966a..652d6b8a90ebb8e761aa7ab01902802d93bfecae 100644 --- a/paddle/framework/tensor_impl.h +++ b/paddle/framework/tensor_impl.h @@ -61,7 +61,7 @@ static inline size_t SizeOfType(std::type_index type) { inline void Tensor::check_memory_size() const { PADDLE_ENFORCE_NOT_NULL( holder_, "Tensor holds no memory. Call Tensor::mutable_data first."); - PADDLE_ENFORCE_GE( + PADDLE_ENFORCE_LE( numel() * SizeOfType(type()), memory_size(), "Tensor's dims_ is out of bound. Call Tensor::mutable_data " "first to re-allocate memory.\n"