Skip to content

Commit

Permalink
Fix BFloat16 extension (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd authored Dec 12, 2024
1 parent a1c3b21 commit 355a783
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ext/BFloat16sExt.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module BFloat16sExt

using LLVM
using LLVM: API
using LLVM: API, BFloatType

using BFloat16s

Expand All @@ -12,7 +12,7 @@ LLVM.ConstantFP(val::BFloat16) = ConstantFP(BFloatType(), val)
Base.convert(::Type{BFloat16}, val::ConstantFP) =
convert(BFloat16, API.LLVMConstRealGetDouble(val, Ref{API.LLVMBool}()))

ConstantDataArray(data::AbstractVector{BFloat16}) =
LLVM.ConstantDataArray(data::AbstractVector{BFloat16}) =
ConstantDataArray(BFloatType(), data)

end
4 changes: 3 additions & 1 deletion test/core_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ end
typ = LLVM.BFloatType()
c = ConstantFP(typ, BFloat16(1.1))
@test convert(BFloat16, c) == BFloat16(1.1)
d = ConstantFP(BFloat16(1.1))
@test convert(BFloat16, d) == BFloat16(1.1)
end
let
typ = LLVM.X86FP80Type()
Expand Down Expand Up @@ -551,7 +553,7 @@ end
@test size(vec) == size(cda)
@test collect(cda) == ConstantInt.(vec)
end
for T in [Float32, Float64]
for T in [Float32, Float64, BFloat16]
vec = T[1,2,3,4]
cda = ConstantDataArray(vec)
@test cda isa ConstantDataArray
Expand Down

0 comments on commit 355a783

Please sign in to comment.