Skip to content

Commit

Permalink
chore: include support for Bigarray.Float16
Browse files Browse the repository at this point in the history
  • Loading branch information
zshipko committed Mar 26, 2024
1 parent 30b918a commit 82a1fcc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ module U16 = struct
let to_float = float_of_int
end

module F16 = struct
type t = float
type elt = float16_elt
type kind = (t, elt) Bigarray.kind

let name = "f16"
let kind = Float16
let of_float x = x
let to_float x = x
end


module F32 = struct
type t = float
type elt = float32_elt
Expand Down Expand Up @@ -87,13 +99,15 @@ type i32 = int32_elt
type i64 = int64_elt
type f32 = float32_elt
type f64 = float64_elt
type f16 = float16_elt

let u8 : (int, u8) t = (module U8)
let u16 : (int, u16) t = (module U16)
let i32 : (int32, i32) t = (module I32)
let i64 : (int64, i64) t = (module I64)
let f32 : (float, f32) t = (module F32)
let f64 : (float, f64) t = (module F64)
let f16 : (float, f16) t = (module F16)
let name : type a b. (a, b) t -> string = fun (module T) -> T.name

let depth : type a b. (a, b) t -> int =
Expand Down
2 changes: 2 additions & 0 deletions src/type.mli
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ type i32 = int32_elt
type i64 = int64_elt
type f32 = float32_elt
type f64 = float64_elt
type f16 = float16_elt

val u8 : (int, u8) t
val u16 : (int, u16) t
val i32 : (int32, i32) t
val i64 : (int64, i64) t
val f32 : (float, f32) t
val f64 : (float, f64) t
val f16: (float, f16) t

0 comments on commit 82a1fcc

Please sign in to comment.