Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Refactor Fixed Point Representation to Use Native Signed Integers #633

@raphaelDkhn

Description

@raphaelDkhn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions