Skip to content
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

Fix a bug on sqfp16 test #1477

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/test/java/org/opensearch/knn/jni/JNIServiceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
import static org.opensearch.knn.common.KNNConstants.PARAMETERS;

public class JNIServiceTests extends KNNTestCase {

static final int FP16_MAX = 65504;
static final int FP16_MIN = -65504;
static TestUtils.TestData testData;
static TestUtils.TestData testDataNested;
private String faissMethod = "HNSW32,Flat";
Expand Down Expand Up @@ -553,9 +554,9 @@ private float[][] truncateToFp16Range(final float[][] data) {
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[i].length; j++) {
float value = data[i][j];
if (value < Float.MIN_VALUE || value > Float.MAX_VALUE) {
if (value < FP16_MIN || value > FP16_MAX) {
// If value is outside of the range, set it to the maximum or minimum value
result[i][j] = value < 0 ? -Float.MAX_VALUE : Float.MAX_VALUE;
result[i][j] = value < 0 ? FP16_MIN : FP16_MAX;
} else {
result[i][j] = value;
}
Expand Down
Loading