Skip to content

Commit

Permalink
LowPrecArray tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed Mar 5, 2025
1 parent 1db9477 commit 5b94c4f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lowprecarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import LinearAlgebra: generic_matmatmul!
function generic_matmatmul!(C::AbstractMatrix{Float32}, ta, tb,
A::Union{LowPrecArray, AbstractMatrix{BFloat16}},
B::Union{LowPrecArray, AbstractMatrix{BFloat16}})
@info "hello"
generic_matmatmul!(C, ta, tb,
MatMulView(A), MatMulView(B))
end
Expand All @@ -46,5 +47,6 @@ end
function LinearAlgebra.BLAS.gemv!(trans::AbstractChar, alpha::Float32,
A::AbstractVecOrMat{Float32}, X::AbstractVector{Float32},
beta::Float32, Y::LowPrecArray)
@info "hello"
LinearAlgebra.BLAS.gemv!(trans, alpha, A, X, beta, Y.storage)
end
22 changes: 22 additions & 0 deletions test/lowprecarrays.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@testset "lowprecarrays" begin
A = rand(Float32, 10,10)
lpA = LowPrecArray(A)

@test lpA isa LowPrecArray
@test size(A) == size(lpA)

lpA[3] = 4
@test lpA[3] == A[3]

a = BFloat16s.ExpandingBFloat16(1f0)
b = BFloat16s.ExpandingBFloat16(1f0)

@test a isa BFloat16s.ExpandingBFloat16
@test a.a isa BFloat16

B = LowPrecArray(rand(Float32, 10,10))
C = LowPrecArray(rand(Float32, 10,10))

lpA .= B*C

end # @testset "lowprecarrays"

0 comments on commit 5b94c4f

Please sign in to comment.