Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #21903: [XLA:CPU] Add __truncsfhf2 and __extendhfsf2 runtime symbols. #21907

Merged
merged 1 commit into from
Jan 27, 2025
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
21 changes: 19 additions & 2 deletions xla/service/cpu/runtime_symbol_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down Expand Up @@ -216,6 +226,13 @@ static bool RegisterKnownJITSymbols() {
"Host");
registry->Register("__truncsfbf2", reinterpret_cast<void*>(__truncsfbf2),
"Host");

#ifdef __APPLE__
registry->Register("__truncsfhf2", reinterpret_cast<void*>(__truncsfhf2),
"Host");
registry->Register("__extendhfsf2", reinterpret_cast<void*>(__extendhfsf2),
"Host");
#endif // __APPLE__
registry->Register("__powisf2", reinterpret_cast<void*>(__powisf2), "Host");
registry->Register("__powidf2", reinterpret_cast<void*>(__powidf2), "Host");

Expand Down
Loading