Skip to content

Commit 5d26c75

Browse files
authored
Fix Metal GPU (#67)
* Fix fill! invokation The solver fails because fill! is called with Float64 (0.0) on Float32 Metal array. Metal GPU cannot handle Float64 operations. * Update FixedEffectCoefficients.jl
1 parent c946d7e commit 5d26c75

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/AbstractFixedEffectSolver.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ function FixedEffects.solve_coefficients!(r::AbstractVector, feM::AbstractFixedE
172172
if !(feM.weights isa UnitWeights)
173173
feM.b .*= sqrt.(feM.weights)
174174
end
175-
fill!(feM.x, 0.0)
175+
fill!(feM.x, zero(T))
176176
x, ch = lsmr!(feM.x, feM.m, feM.b, feM.v, feM.h, feM.hbar; atol = tol, btol = tol, maxiter = maxiter)
177177
for (x, scale) in zip(feM.x.x, feM.m.scales)
178178
x .*= scale
179179
end
180180
x = Vector{eltype(r)}[collect(x) for x in feM.x.x]
181181
full(normalize!(x, feM.m.fes; tol = tol, maxiter = maxiter), feM.m.fes), div(ch.mvps, 2), ch.isconverged
182-
end
182+
end

src/FixedEffectCoefficients.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Define methods used in LSMR
1+
e# Define methods used in LSMR
22

33
##############################################################################
44
##
@@ -28,14 +28,14 @@ end
2828

2929
function Base.fill!(fecoefs::FixedEffectCoefficients, α::Number)
3030
for x in fecoefs.x
31-
fill!(x, α)
31+
fill!(x, eltype(fecoefs)(α))
3232
end
3333
return fecoefs
3434
end
3535

3636
function LinearAlgebra.rmul!(fecoefs::FixedEffectCoefficients, α::Number)
3737
for x in fecoefs.x
38-
rmul!(x, α)
38+
rmul!(x, eltype(fecoefs)(α))
3939
end
4040
return fecoefs
4141
end
@@ -52,4 +52,4 @@ function LinearAlgebra.axpy!(α::Number, fecoefs1::FixedEffectCoefficients, feco
5252
axpy!(α, x1, x2)
5353
end
5454
return fecoefs2
55-
end
55+
end

0 commit comments

Comments
 (0)