diff --git a/xla/service/cpu/runtime_symbol_generator.cc b/xla/service/cpu/runtime_symbol_generator.cc index f0a0742a2e299..c022e26bb7624 100644 --- a/xla/service/cpu/runtime_symbol_generator.cc +++ b/xla/service/cpu/runtime_symbol_generator.cc @@ -115,11 +115,21 @@ RuntimeSymbolGenerator::ResolveRuntimeSymbol(llvm::StringRef name) { extern "C" void __chkstk(size_t); #endif +extern "C" { // Provided by compiler-rt and MLIR. // Converts an F32 value to a BF16. -extern "C" uint16_t __truncsfbf2(float); +uint16_t __truncsfbf2(float); // Converts an F64 value to a BF16. -extern "C" uint16_t __truncdfbf2(double); +uint16_t __truncdfbf2(double); + +#ifdef __APPLE__ +// Converts an F32 value to a F16. +uint16_t __truncsfhf2(float); + +float __extendhfsf2(uint16_t a); +#endif // __APPLE__ + +} // extern "C" #define REGISTER_CPU_RUNTIME_SYMBOL(base_name) \ do { \ @@ -216,6 +226,13 @@ static bool RegisterKnownJITSymbols() { "Host"); registry->Register("__truncsfbf2", reinterpret_cast(__truncsfbf2), "Host"); + +#ifdef __APPLE__ + registry->Register("__truncsfhf2", reinterpret_cast(__truncsfhf2), + "Host"); + registry->Register("__extendhfsf2", reinterpret_cast(__extendhfsf2), + "Host"); +#endif // __APPLE__ registry->Register("__powisf2", reinterpret_cast(__powisf2), "Host"); registry->Register("__powidf2", reinterpret_cast(__powidf2), "Host");