Skip to content

Commit 355a783

Browse files
Fix BFloat16 extension (#493)
1 parent a1c3b21 commit 355a783

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ext/BFloat16sExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module BFloat16sExt
22

33
using LLVM
4-
using LLVM: API
4+
using LLVM: API, BFloatType
55

66
using BFloat16s
77

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

15-
ConstantDataArray(data::AbstractVector{BFloat16}) =
15+
LLVM.ConstantDataArray(data::AbstractVector{BFloat16}) =
1616
ConstantDataArray(BFloatType(), data)
1717

1818
end

test/core_tests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ end
421421
typ = LLVM.BFloatType()
422422
c = ConstantFP(typ, BFloat16(1.1))
423423
@test convert(BFloat16, c) == BFloat16(1.1)
424+
d = ConstantFP(BFloat16(1.1))
425+
@test convert(BFloat16, d) == BFloat16(1.1)
424426
end
425427
let
426428
typ = LLVM.X86FP80Type()
@@ -551,7 +553,7 @@ end
551553
@test size(vec) == size(cda)
552554
@test collect(cda) == ConstantInt.(vec)
553555
end
554-
for T in [Float32, Float64]
556+
for T in [Float32, Float64, BFloat16]
555557
vec = T[1,2,3,4]
556558
cda = ConstantDataArray(vec)
557559
@test cda isa ConstantDataArray

0 commit comments

Comments
 (0)