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

Support for other floating point types #1140

Open
fzhwenzhou opened this issue Jan 31, 2025 · 5 comments
Open

Support for other floating point types #1140

fzhwenzhou opened this issue Jan 31, 2025 · 5 comments
Labels

Comments

@fzhwenzhou
Copy link


Feature request

Is there any plan to support other floating point types as LLVM C/C++ bindings support, like bf16, x86 fp80, or fp128? It would be of a great convenience to implement data types like "long double" and "__bf16" in C/C++. Thank you!

@esc esc added the question label Feb 3, 2025
@esc
Copy link
Member

esc commented Feb 3, 2025

@fzhwenzhou I will ask in the developer meeting tomorrow and report back.

@esc esc added the enhancement label Feb 4, 2025
@esc
Copy link
Member

esc commented Feb 4, 2025

@fzhwenzhou this depends on the inclusion of compiler-rt -- and once that is done, it'll be a load more work, to the best of my knowledge there are currently no concrete plans for anyone to implement this.

We wanted to ask as to what your use-case for these types is and how they can make a difference for you?

@fzhwenzhou
Copy link
Author

@fzhwenzhou this depends on the inclusion of compiler-rt -- and once that is done, it'll be a load more work, to the best of my knowledge there are currently no concrete plans for anyone to implement this.

We wanted to ask as to what your use-case for these types is and how they can make a difference for you?

We are implementing a DSL targeting GPUs using LLVM backends, and BF16 is important for various machine learning tasks. In LLVM C++ bindings, we can directly use the data type LLVMBFloatType. However, in llvmlite there is no such data type. A workaround we are adopting is to extract the exponent and fraction part ourselves, use bit operations to construct an integer, and store it into ir.IntType(16). It is not hard actually. Nevertheless, it is neither straightforward nor can it perform any arithmetic operations. Thus, I hope you can add some other floating point types like BF16. Thanks!

@esc esc added feature_request Feature Request and removed question labels Feb 5, 2025
@esc
Copy link
Member

esc commented Feb 5, 2025

@fzhwenzhou thank you for the update. I have labeld this as a feature request.

@lesshaste
Copy link

lesshaste commented Feb 5, 2025

I would love support for FP128 and/or FP80. FP80 would allow numpy.float128 to work in numba for example (it is secretly a long double). They are both already supported in llvm I believe. Currently I have to use pythran instead of numba if I want to use long doubles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants