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

Refactor Fixed Point Representation to Use Native Signed Integers #633

Open
raphaelDkhn opened this issue Apr 22, 2024 · 1 comment
Open
Assignees
Labels

Comments

@raphaelDkhn
Copy link
Collaborator

raphaelDkhn commented Apr 22, 2024

Currently, fixed points in Orion are represented by a struct defined as follows:

FP {
  mag: usize,
  sign: bool
}

The mag field represents the magnitude, and the sign field indicates the sign of the number, with false being positive and true being negative. This structure was initially chosen because Cairo did not natively support signed integers at the time. Presently, we support four fixed point types: FP16x16, FP8x23, FP32x32, and FP64x64. The last two types were adopted from the Cubit library.

Given that Cairo now natively supports signed integers, we should update our fixed point implementation to use native signed integers instead of the current struct-based approach.

Given the extensive changes required, an initial PR could focus on the FP16x16 implementation. Since the Tensor and NN libraries heavily rely on FP16x16, we can start by introducing a new implementation in the fixed point directory named f16x16. This will allow us to refactor without removing the existing FP16x16 implementation and plan further updates in the Tensor and NN libraries in subsequent PRs.

@zintarh
Copy link

zintarh commented Apr 22, 2024

Hi @raphaelDkhn I would like to work on this

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

2 participants