Skip to content

Fix Sign and Clip operation on int64 tensors - #25280

Closed
Christian Bourjau (cbourjau) wants to merge 3 commits into
microsoft:mainfrom
cbourjau:fix-clip-sign
Closed

Christian Bourjau (cbourjau) wants to merge 3 commits into
microsoft:mainfrom
cbourjau:fix-clip-sign

Conversation

@cbourjau

@cbourjau Christian Bourjau (cbourjau) commented Jul 3, 2025 •

Copy link
Copy Markdown
Contributor

Description

The Clip and sign operators exhibit buggy behavior for some int64 values on Linux and Windows (see added test cases). Using Eigen's Array-API appears to mitigate the issue. A failing test case on CI can be found here (uses the conda-forge toolchain).

Signed-off-by: Christian Bourjau <christian.bourjau@quantco.com>
@cbourjau Christian Bourjau (cbourjau) changed the title Add failing test cases Fix Sign and Clip operation on int64 tensors Jul 3, 2025
Signed-off-by: Christian Bourjau <christian.bourjau@quantco.com>
@cbourjau
Christian Bourjau (cbourjau) marked this pull request as ready for review July 4, 2025 15:06
@@ -0,0 +1,33 @@
import numpy as np
import onnx

Check notice

Code scanning / CodeQL

Module is imported with 'import' and 'import from'

Module 'onnx' is imported with both 'import' and 'import from'. Module 'onnxruntime.test.onnx' is imported with both 'import' and 'import from'.
@@ -0,0 +1,32 @@
import numpy as np
import onnx

Check notice

Code scanning / CodeQL

Module is imported with 'import' and 'import from'

Module 'onnx' is imported with both 'import' and 'import from'. Module 'onnxruntime.test.onnx' is imported with both 'import' and 'import from'.
@tianleiwu

Copy link
Copy Markdown
Contributor

/azp run Linux QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI, Windows ARM64 QNN CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows x64 QNN CI Pipeline

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 5 pipeline(s).

@cbourjau

Copy link
Copy Markdown
Contributor Author

Sorry, I lost sight of this PR. However, I was now able to fine the correct cause for this issue. The currenly-used Eigen version is buggy on SSE2 code paths. There is a fix upstream, but it is not part of any release, yet: https://gitlab.com/libeigen/eigen/-/merge_requests/2831

@cbourjau

Copy link
Copy Markdown
Contributor Author

I'm closing this in favor of #32475

eserscor pushed a commit that referenced this pull request Nov 11, 2026
### Description
onnxruntime is currently using an Eigen commit from somewhere in between
Eigen 3.4.1 and Eigen 5.0.1 (despite the comment in deps.txt). This PR
updates Eigen to the latest 5.0.1 release. Note that Eigen is a
headers-only library, which should make this process smooth.

One of the currently applied patches is no longer needed (it is part of
the 5.0.1 release), and the other is simply disabling some warnings
(still present after this PR). The new patch backports an [upstream
fix](https://gitlab.com/libeigen/eigen/-/merge_requests/2831) for a bug
which I had attempted to fix
[here](#25280) somewhat
incorrectly a long time ago. My proposed fix merely avoided the broken
SSE2 code path.


### Motivation and Context
The main motivation is to properly fix the Sign and Clip operators on
installations that use the SSE2 path. Onnxruntime is currently using an
outdated and odd Eigen version, which makes backporting awkward. It
seems much easier and generally beneficial to update Eigen to a proper
release, plus some well-defined patches.

---------

Signed-off-by: Christian Bourjau <christian.bourjau@quantco.com>
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.

3 participants