Skip to content

Fix Sign and Clip operation on int64 tensors #25280

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cbourjau
Copy link
Contributor

@cbourjau cbourjau commented Jul 3, 2025

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 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 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' Note test

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' Note test

Module 'onnx' is imported with both 'import' and 'import from'.
Module 'onnxruntime.test.onnx' is imported with both 'import' and 'import from'.
.cwiseMin(max_val);
.array()
.unaryExpr([=](auto x) {
return std::clamp(x, min_val, max_val);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will not get expected result when min_val > max_val. std::clamp will return x in this case, while onnx definition is Min(max_value, Max(x, min_value)) will return max_value.

@tianleiwu
Copy link
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

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

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