diff --git a/paddle/fluid/eager/nan_inf_utils.cc b/paddle/fluid/eager/nan_inf_utils.cc index c183c64fa7a1d77010f5b6c422a59166bb9665a1..a66bc211d513c3a1092ef15c9a0a4530f411b945 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); } }