Skip to content

Commit 6e444b6

Browse files
committed
Fix a bug on sqfp16 test
Signed-off-by: Heemin Kim <heemin@amazon.com>
1 parent e2d5bc5 commit 6e444b6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/test/java/org/opensearch/knn/jni/JNIServiceTests.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
import static org.opensearch.knn.common.KNNConstants.PARAMETERS;
5858

5959
public class JNIServiceTests extends KNNTestCase {
60-
60+
static final int FP16_MAX = 65504;
61+
static final int FP16_MIN = -65504;
6162
static TestUtils.TestData testData;
6263
static TestUtils.TestData testDataNested;
6364
private String faissMethod = "HNSW32,Flat";
@@ -553,9 +554,9 @@ private float[][] truncateToFp16Range(final float[][] data) {
553554
for (int i = 0; i < data.length; i++) {
554555
for (int j = 0; j < data[i].length; j++) {
555556
float value = data[i][j];
556-
if (value < Float.MIN_VALUE || value > Float.MAX_VALUE) {
557+
if (value < FP16_MIN || value > FP16_MAX) {
557558
// If value is outside of the range, set it to the maximum or minimum value
558-
result[i][j] = value < 0 ? -Float.MAX_VALUE : Float.MAX_VALUE;
559+
result[i][j] = value < 0 ? FP16_MIN : FP16_MAX;
559560
} else {
560561
result[i][j] = value;
561562
}

0 commit comments

Comments
 (0)