Add predefined datatypes for FP8 formats (#5882)

Adds predefined datatypes for FP8 data in E4M3 and E5M2 formats

Does not add support for any native FP8 types; datatype conversions are performed in software
This commit is contained in:
jhendersonHDF
2025-11-03 15:10:22 -06:00
committed by GitHub
parent 135c31b3c3
commit eb72e67ed2
41 changed files with 2592 additions and 732 deletions
+8
View File
@@ -1125,6 +1125,10 @@ public class HDF5Constants {
/** */
public static final long H5T_FLOAT_BFLOAT16LE = H5T_FLOAT_BFLOAT16LE();
/** */
public static final long H5T_FLOAT_F8E4M3 = H5T_FLOAT_F8E4M3();
/** */
public static final long H5T_FLOAT_F8E5M2 = H5T_FLOAT_F8E5M2();
/** */
public static final int H5T_INTEGER = H5T_INTEGER();
/** */
public static final long H5T_INTEL_B16 = H5T_INTEL_B16();
@@ -2640,6 +2644,10 @@ public class HDF5Constants {
private static native final long H5T_FLOAT_BFLOAT16LE();
private static native final long H5T_FLOAT_F8E4M3();
private static native final long H5T_FLOAT_F8E5M2();
private static native final int H5T_INTEGER();
private static native final long H5T_INTEL_B16();
+10
View File
@@ -2746,6 +2746,16 @@ Java_hdf_hdf5lib_HDF5Constants_H5T_1FLOAT_1BFLOAT16LE(JNIEnv *env, jclass cls)
{
return H5T_FLOAT_BFLOAT16LE;
}
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1FLOAT_1F8E4M3(JNIEnv *env, jclass cls)
{
return H5T_FLOAT_F8E4M3;
}
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1FLOAT_1F8E5M2(JNIEnv *env, jclass cls)
{
return H5T_FLOAT_F8E5M2;
}
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEGER(JNIEnv *env, jclass cls)
{
+22 -2
View File
@@ -2166,7 +2166,13 @@ h5str_get_little_endian_type(hid_t tid)
}
case H5T_FLOAT: {
if (size == 2) {
if (size == 1) {
if (true == H5Tequal(tid, H5T_FLOAT_F8E4M3))
p_type = H5Tcopy(H5T_FLOAT_F8E4M3);
else if (true == H5Tequal(tid, H5T_FLOAT_F8E5M2))
p_type = H5Tcopy(H5T_FLOAT_F8E5M2);
}
else if (size == 2) {
if (true == H5Tequal(tid, H5T_IEEE_F16LE) || true == H5Tequal(tid, H5T_IEEE_F16BE))
p_type = H5Tcopy(H5T_IEEE_F16LE);
else if (true == H5Tequal(tid, H5T_FLOAT_BFLOAT16LE) ||
@@ -2278,7 +2284,21 @@ h5str_get_big_endian_type(hid_t tid)
}
case H5T_FLOAT: {
if (size == 2) {
if (size == 1) {
if (true == H5Tequal(tid, H5T_FLOAT_F8E4M3)) {
p_type = H5Tcopy(H5T_FLOAT_F8E4M3);
/* Though not very useful, set order to BE as expected */
H5Tset_order(p_type, H5T_ORDER_BE);
}
else if (true == H5Tequal(tid, H5T_FLOAT_F8E5M2)) {
p_type = H5Tcopy(H5T_FLOAT_F8E5M2);
/* Though not very useful, set order to BE as expected */
H5Tset_order(p_type, H5T_ORDER_BE);
}
}
else if (size == 2) {
if (true == H5Tequal(tid, H5T_IEEE_F16LE) || true == H5Tequal(tid, H5T_IEEE_F16BE))
p_type = H5Tcopy(H5T_IEEE_F16BE);
else if (true == H5Tequal(tid, H5T_FLOAT_BFLOAT16LE) ||