diff --git a/paddle/phi/core/framework/data_type_transform.cc b/paddle/phi/core/framework/data_type_transform.cc index 6ed397d85d378e..8ec86fa02e4e45 100644 --- a/paddle/phi/core/framework/data_type_transform.cc +++ b/paddle/phi/core/framework/data_type_transform.cc @@ -30,7 +30,26 @@ namespace phi { template struct CastDataTypeFunctor { HOSTDEVICE inline OutType operator()(InType in) const { +#if defined(_MSC_VER) + // Avoid unsupported convert of float/bfloat8/float16 -> complex + if constexpr ( + (std::is_same_v> || + std::is_same_v< + OutType, + phi::dtype::complex< + double>>)&&(std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v)) { + // default value,only to avoid compile error + return OutType(0); + } else { + return static_cast(in); + } +#else return static_cast(in); +#endif } };