-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Christian Bourjau <christian.bourjau@quantco.com>
Signed-off-by: Christian Bourjau <christian.bourjau@quantco.com>
@@ -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 '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 '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); |
There was a problem hiding this comment.
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.
/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 successfully started running 5 pipeline(s). |
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).