@@ -86,13 +86,14 @@ hdf5_type_id(::Type{Int32}) = H5T.NATIVE_INT32
8686hdf5_type_id (:: Type{UInt32} ) = H5T. NATIVE_UINT32
8787hdf5_type_id (:: Type{Int64} ) = H5T. NATIVE_INT64
8888hdf5_type_id (:: Type{UInt64} ) = H5T. NATIVE_UINT64
89+ hdf5_type_id (:: Type{Float16} ) = H5T. NATIVE_FLOAT16
8990hdf5_type_id (:: Type{Float32} ) = H5T. NATIVE_FLOAT
9091hdf5_type_id (:: Type{Float64} ) = H5T. NATIVE_DOUBLE
9192hdf5_type_id (:: Type{Reference} ) = H5T. STD_REF_OBJ
9293
9394hdf5_type_id (:: Type{S} ) where {S<: AbstractString } = H5T. C_S1
9495
95- const BitsType = Union{Bool,Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64,Float32,Float64}
96+ const BitsType = Union{Bool,Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64,Float16, Float32,Float64}
9697const ScalarType = Union{BitsType,Reference}
9798
9899# It's not safe to use particular id codes because these can change, so we use characteristics of the type.
@@ -112,7 +113,8 @@ function _hdf5_type_map(class_id, is_signed, native_size)
112113 throw (KeyError (class_id, is_signed, native_size))
113114 end
114115 else
115- return native_size === Csize_t (4 ) ? Float32 :
116+ return native_size === Csize_t (2 ) ? Float16 :
117+ native_size === Csize_t (4 ) ? Float32 :
116118 native_size === Csize_t (8 ) ? Float64 :
117119 throw (KeyError (class_id, is_signed, native_size))
118120 end
@@ -1934,6 +1936,14 @@ function __init__()
19341936 __init_globals__ ()
19351937 register_blosc ()
19361938
1939+ # Generate the Float16 datatype:
1940+ float16 = h5t_copy (H5T. NATIVE_FLOAT)
1941+ h5t_set_fields (float16, 15 , 10 , 5 , 0 , 10 )
1942+ h5t_set_size (float16, 2 )
1943+ h5t_set_ebias (float16, 15 )
1944+ h5t_lock (float16)
1945+ H5T. NATIVE_FLOAT16 = float16
1946+
19371947 # Turn off automatic error printing
19381948 # h5e_set_auto(H5E.DEFAULT, C_NULL, C_NULL)
19391949
0 commit comments