Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions paddle/phi/core/framework/data_type_transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,26 @@ namespace phi {
template <typename InType, typename OutType>
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<OutType, phi::dtype::complex<float>> ||
std::is_same_v<
OutType,
phi::dtype::complex<
double>>)&&(std::is_same_v<InType,
phi::dtype::float8_e4m3fn> ||
std::is_same_v<InType, phi::dtype::float8_e5m2> ||
std::is_same_v<InType, phi::dtype::bfloat16> ||
std::is_same_v<InType, phi::dtype::float16>)) {
// default value,only to avoid compile error
return OutType(0);
} else {
return static_cast<OutType>(in);
}
#else
return static_cast<OutType>(in);
#endif
}
};

Expand Down
Loading