diff --git a/paddle/fluid/eager/nan_inf_utils.h b/paddle/fluid/eager/nan_inf_utils.h index 815e3bd6cd14f11eac3044e67322ad8975f1bf5d..9abc1ca02f168ac1993f1231193c0ddc4a43b7ac 100644 --- a/paddle/fluid/eager/nan_inf_utils.h +++ b/paddle/fluid/eager/nan_inf_utils.h @@ -62,4 +62,25 @@ void CheckTensorHasNanOrInf( const paddle::small_vector, egr::kSlotSmallVectorSize>& tensors); +template +struct NanInfChecker { + void operator()(const std::string& api_name, const TupleT& tensors) { + CheckTensorHasNanOrInf(api_name, std::get(tensors)); + NanInfChecker()(api_name, tensors); + } +}; + +template +struct NanInfChecker { + void operator()(const std::string& api_name, const TupleT& tensors) { + CheckTensorHasNanOrInf(api_name, std::get(tensors)); + } +}; + +template +void CheckTensorHasNanOrInf(const std::string& api_name, + const TupleT& tensors) { + constexpr size_t size = std::tuple_size::value; + NanInfChecker()(api_name, tensors); +} } // namespace egr diff --git a/paddle/phi/api/yaml/generator/api_gen.py b/paddle/phi/api/yaml/generator/api_gen.py index 64c2fac85cd0028e684dde86fa0a88f2671ae837..dc4581472f847e7bd3a6749966614a8f592da84d 100644 --- a/paddle/phi/api/yaml/generator/api_gen.py +++ b/paddle/phi/api/yaml/generator/api_gen.py @@ -130,7 +130,7 @@ class ForwardAPI(BaseAPI): selected_code = [ f"std::get<{i}>(api_output)" for i in return_out_list ] - return 'return {' + ", ".join(selected_code) + '};' + return 'return std::make_tuple(' + ", ".join(selected_code) + ');' def gene_output(self, out_dtype_list,