mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-22 17:08:52 +00:00
8386322: Float16Vector.toString should render lane values using Float16.toString
Reviewed-by: psandoz, rgiulietti
This commit is contained in:
parent
be40b6bcda
commit
6e2a4f847f
@ -3707,8 +3707,10 @@ public abstract sealed class Float16Vector extends AbstractVector<Float16>
|
||||
* in lane order.
|
||||
*
|
||||
* The string is produced as if by a call to {@link
|
||||
* java.util.Arrays#toString(short[]) Arrays.toString()},
|
||||
* as appropriate to the {@code short} array returned by
|
||||
* java.util.Arrays#toString(Object[]) Arrays.toString()},
|
||||
* as appropriate to a {@code Float16} array whose elements
|
||||
* are obtained by applying {@link Float16#shortBitsToFloat16(short)}
|
||||
* to each element of the {@code short[]} array returned by
|
||||
* {@link #toArray this.toArray()}.
|
||||
*
|
||||
* @return a string of the form {@code "[0,1,2...]"}
|
||||
@ -3718,8 +3720,10 @@ public abstract sealed class Float16Vector extends AbstractVector<Float16>
|
||||
@ForceInline
|
||||
public final
|
||||
String toString() {
|
||||
// now that toArray is strongly typed, we can define this
|
||||
return Arrays.toString(toArray());
|
||||
// Render the lanes as Float16 values; Float16.toString produces
|
||||
// human-readable text and canonicalizes NaN, Infinity and -0.0
|
||||
// independent of the underlying bit encoding.
|
||||
return Arrays.toString(toFloat16Array());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -5723,10 +5723,19 @@ public abstract sealed class $abstractvectortype$ extends AbstractVector<$Boxtyp
|
||||
* {@code "[0,1,2...]"}, reporting the lane values of this vector,
|
||||
* in lane order.
|
||||
*
|
||||
#if[FP16]
|
||||
* The string is produced as if by a call to {@link
|
||||
* java.util.Arrays#toString(Object[]) Arrays.toString()},
|
||||
* as appropriate to a {@code Float16} array whose elements
|
||||
* are obtained by applying {@link Float16#shortBitsToFloat16(short)}
|
||||
* to each element of the {@code short[]} array returned by
|
||||
* {@link #toArray this.toArray()}.
|
||||
#else[FP16]
|
||||
* The string is produced as if by a call to {@link
|
||||
* java.util.Arrays#toString($type$[]) Arrays.toString()},
|
||||
* as appropriate to the {@code $type$} array returned by
|
||||
* {@link #toArray this.toArray()}.
|
||||
#end[FP16]
|
||||
*
|
||||
* @return a string of the form {@code "[0,1,2...]"}
|
||||
* reporting the lane values of this vector
|
||||
@ -5735,8 +5744,15 @@ public abstract sealed class $abstractvectortype$ extends AbstractVector<$Boxtyp
|
||||
@ForceInline
|
||||
public final
|
||||
String toString() {
|
||||
#if[FP16]
|
||||
// Render the lanes as Float16 values; Float16.toString produces
|
||||
// human-readable text and canonicalizes NaN, Infinity and -0.0
|
||||
// independent of the underlying bit encoding.
|
||||
return Arrays.toString(toFloat16Array());
|
||||
#else[FP16]
|
||||
// now that toArray is strongly typed, we can define this
|
||||
return Arrays.toString(toArray());
|
||||
#end[FP16]
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -5412,7 +5412,8 @@ public class Float16Vector128Tests extends AbstractVectorTest {
|
||||
String str = av.toString();
|
||||
|
||||
short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
|
||||
Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
|
||||
String expectedStr = Arrays.toString(toFloat16Array(subarr));
|
||||
Assert.assertTrue(str.equals(expectedStr), "at index " + i + ", string should be = " + expectedStr + ", but is = " + str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5412,7 +5412,8 @@ public class Float16Vector256Tests extends AbstractVectorTest {
|
||||
String str = av.toString();
|
||||
|
||||
short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
|
||||
Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
|
||||
String expectedStr = Arrays.toString(toFloat16Array(subarr));
|
||||
Assert.assertTrue(str.equals(expectedStr), "at index " + i + ", string should be = " + expectedStr + ", but is = " + str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5412,7 +5412,8 @@ public class Float16Vector512Tests extends AbstractVectorTest {
|
||||
String str = av.toString();
|
||||
|
||||
short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
|
||||
Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
|
||||
String expectedStr = Arrays.toString(toFloat16Array(subarr));
|
||||
Assert.assertTrue(str.equals(expectedStr), "at index " + i + ", string should be = " + expectedStr + ", but is = " + str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5412,7 +5412,8 @@ public class Float16Vector64Tests extends AbstractVectorTest {
|
||||
String str = av.toString();
|
||||
|
||||
short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
|
||||
Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
|
||||
String expectedStr = Arrays.toString(toFloat16Array(subarr));
|
||||
Assert.assertTrue(str.equals(expectedStr), "at index " + i + ", string should be = " + expectedStr + ", but is = " + str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5418,7 +5418,8 @@ public class Float16VectorMaxTests extends AbstractVectorTest {
|
||||
String str = av.toString();
|
||||
|
||||
short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
|
||||
Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
|
||||
String expectedStr = Arrays.toString(toFloat16Array(subarr));
|
||||
Assert.assertTrue(str.equals(expectedStr), "at index " + i + ", string should be = " + expectedStr + ", but is = " + str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +87,12 @@
|
||||
String str = av.toString();
|
||||
|
||||
$type$ subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
|
||||
Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
|
||||
#if[FP16]
|
||||
String expectedStr = Arrays.toString(toFloat16Array(subarr));
|
||||
#else[FP16]
|
||||
String expectedStr = Arrays.toString(subarr);
|
||||
#end[FP16]
|
||||
Assert.assertTrue(str.equals(expectedStr), "at index " + i + ", string should be = " + expectedStr + ", but is = " + str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user