From 46fe73f8909dcd444a5a2375c26ee32a5628c222 Mon Sep 17 00:00:00 2001 From: niuliling123 Date: Thu, 27 Apr 2023 11:19:13 +0000 Subject: [PATCH] Fix core dumped in training when check_nan_inf=1 --- paddle/fluid/eager/nan_inf_utils.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/eager/nan_inf_utils.cc b/paddle/fluid/eager/nan_inf_utils.cc index c183c64fa7a..a66bc211d51 100644 --- a/paddle/fluid/eager/nan_inf_utils.cc +++ b/paddle/fluid/eager/nan_inf_utils.cc @@ -115,7 +115,9 @@ void CheckTensorHasNanOrInf(const std::string& api_name, const Tensor& tensor) { void CheckTensorHasNanOrInf(const std::string& api_name, const paddle::optional& tensor) { - CheckTensorHasNanOrInf(api_name, tensor.get()); + if (tensor) { + CheckTensorHasNanOrInf(api_name, *tensor); + } } void CheckTensorHasNanOrInf(const std::string& api_name, @@ -169,7 +171,7 @@ void CheckTensorHasNanOrInf( const std::string& api_name, const paddle::optional>& tensors) { if (tensors) { - CheckTensorHasNanOrInf(api_name, tensors.get()); + CheckTensorHasNanOrInf(api_name, *tensors); } } -- GitLab