Skip to content

Fix libdevice iree_f2h_ieee conversion - #20248

Merged
bjacob merged 3 commits into
iree-org:mainfrom
bjacob:fix-libdevice2
Mar 14, 2025
Merged

bjacob merged 3 commits into
iree-org:mainfrom
bjacob:fix-libdevice2

Conversation

@bjacob

@bjacob bjacob commented Mar 14, 2025 •

Copy link
Copy Markdown
Collaborator

This replaces the implementation with a specialized copy of the code we have in base/internal/math.h.

This also adds an extensive test, so that we can feel better about this code which isn't shared with anything else (being libdevice) and is relatively little used, being used only with workloads involving the CPU-hostile f16 type, and only on CPU targets lacking native f16-f32 conversion instructions, which is generally only generic CPU targets as contemporary CPUs tend to have native instructions for these f16-f32 (F16C extension on x86) even though they lack native f16 arithmetic beyond these conversions.

Fixes #20163.

Signed-off-by: Benoit Jacob <[email protected]>
@bjacob
bjacob marked this pull request as ready for review March 14, 2025 18:46
@bjacob
bjacob requested a review from benvanik as a code owner March 14, 2025 18:46
Signed-off-by: Benoit Jacob <[email protected]>
Signed-off-by: Benoit Jacob <[email protected]>
@bjacob
bjacob enabled auto-merge (squash) March 14, 2025 19:24
@bjacob
bjacob merged commit e33829c into iree-org:main Mar 14, 2025
pxanthopoulos pushed a commit to pxanthopoulos/iree that referenced this pull request Mar 17, 2025
This replaces the implementation with a specialized copy of the code we
have in base/internal/math.h.

This also adds an extensive test, so that we can feel better about this
code which isn't shared with anything else (being libdevice) and is
relatively little used, being used only with workloads involving the
CPU-hostile f16 type, and only on CPU targets lacking native f16-f32
conversion instructions, which is generally only `generic` CPU targets
as contemporary CPUs tend to have native instructions for these f16-f32
(F16C extension on x86) even though they lack native f16 *arithmetic*
beyond these conversions.

Fixes iree-org#20163.

---------

Signed-off-by: Benoit Jacob <[email protected]>
Eliasj42 pushed a commit that referenced this pull request Mar 24, 2025
This replaces the implementation with a specialized copy of the code we
have in base/internal/math.h.

This also adds an extensive test, so that we can feel better about this
code which isn't shared with anything else (being libdevice) and is
relatively little used, being used only with workloads involving the
CPU-hostile f16 type, and only on CPU targets lacking native f16-f32
conversion instructions, which is generally only `generic` CPU targets
as contemporary CPUs tend to have native instructions for these f16-f32
(F16C extension on x86) even though they lack native f16 *arithmetic*
beyond these conversions.

Fixes #20163.

---------

Signed-off-by: Benoit Jacob <[email protected]>
Signed-off-by: Elias Joseph <[email protected]>
AWoloszyn pushed a commit that referenced this pull request Dec 1, 2025
This replaces the implementation with a specialized copy of the code we
have in base/internal/math.h.

This also adds an extensive test, so that we can feel better about this
code which isn't shared with anything else (being libdevice) and is
relatively little used, being used only with workloads involving the
CPU-hostile f16 type, and only on CPU targets lacking native f16-f32
conversion instructions, which is generally only `generic` CPU targets
as contemporary CPUs tend to have native instructions for these f16-f32
(F16C extension on x86) even though they lack native f16 *arithmetic*
beyond these conversions.

Fixes #20163.

---------

Signed-off-by: Benoit Jacob <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in f32->f16 truncation on CPU: 0.49990 is truncated to 0.25.

2 participants