Skip to content

[IMEXRunnerUtils] Update Allclose and printMaxError semantics to handle Nan and inf. - #1225

Merged
mshahneo merged 2 commits into
intel:mainfrom
mshahneo:issue_1690_for_upstream
Aug 18, 2026
Merged

[IMEXRunnerUtils] Update Allclose and printMaxError semantics to handle Nan and inf.#1225
mshahneo merged 2 commits into
intel:mainfrom
mshahneo:issue_1690_for_upstream

Conversation

@mshahneo

Copy link
Copy Markdown
Contributor

Add a new set of APIs to matches NumPy semantics for numpy.allclose and numpy.isclose:

- NaNs at the same index are equal *iff* `equal_nan=True`.
- A NaN paired with any non-NaN is never close.
- Infinities are equal *iff* same sign; `+Inf` vs `-Inf` and `Inf` vs finite are not close.

Instead of updating the existing APIs - which
changes their ABI and forces every integration test call site to update — keep the existing extern "C" symbols at their original signatures using numpy's default equal_nan=True, and expose the equal_nan=False behavior through new Strict symbols:

  • allcloseStrict{F16,BF16,F32}
  • printAllcloseStrict{F16,BF16,F32}
  • printMaxErrorStrict{F16,BF16,F32}

For printMaxErrorStrict, additionally surface NaN/Inf mismatches in the printed report rather than letting them disappear into a silent zero.

Please review these guidelines to help with the review process:

  • Have you provided a meaningful PR description?
  • Have you added a test, a reproducer, or a reference to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • If this PR is a work in progress, are you filing the PR as a draft?
  • Have you organized your commits logically and ensured each can be built by itself?

…le Nan and inf.

Add a new set of APIs to matches NumPy semantics for `numpy.allclose` and `numpy.isclose`:

    - NaNs at the same index are equal *iff* `equal_nan=True`.
    - A NaN paired with any non-NaN is never close.
    - Infinities are equal *iff* same sign; `+Inf` vs `-Inf` and `Inf` vs finite are not close.

Instead of updating the existing APIs - which
changes their ABI and forces every integration test call site to update —
keep the existing `extern "C"` symbols at their original signatures using
numpy's default equal_nan=True, and expose the equal_nan=False behavior
through new *Strict* symbols:
  - `allcloseStrict{F16,BF16,F32}`
  - `printAllcloseStrict{F16,BF16,F32}`
  - `printMaxErrorStrict{F16,BF16,F32}`

For `printMaxErrorStrict`, additionally surface NaN/Inf mismatches in the printed
report rather than letting them disappear into a silent zero.
@mshahneo
mshahneo requested a review from Garra1980 August 17, 2026 21:40
Wrap the _mlir_ciface_allclose signature and the tolerated
assignment to satisfy the 80-column limit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mshahneo
mshahneo merged commit 9bd5455 into intel:main Aug 18, 2026
2 checks passed
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.

2 participants