Skip to content

Commit 758d49a

Browse files
committed
fix Adapt handling of eltype
workaround for JuliaGPU/GPUArrays.jl#348 but really I was just using Adapt incorrectly here
1 parent 7f29349 commit 758d49a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/flat_fields.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ function get_Cℓ(f₁::FlatS0, f₂::FlatS0=f₁; Δℓ=50, ℓedges=0:Δℓ:16
549549
ℓmask = (ℓmag .> minimum(ℓedges)) .& (ℓmag .< maximum(ℓedges))
550550
L = ℓmag[ℓmask]
551551
CLobs = 1/α .* real.(dot.(
552-
adapt(Array{Float64},f₁)[:Il, full_plane=true][ℓmask],
553-
adapt(Array{Float64},f₂)[:Il, full_plane=true][ℓmask]
552+
adapt(Array,f₁)[:Il, full_plane=true][ℓmask],
553+
adapt(Array,f₂)[:Il, full_plane=true][ℓmask]
554554
))
555555
w = @. nan2zero((2*Cℓfid(L)^2/(2L+1))^-1)
556556

src/gpu.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ Random.randn(rng::CUDA.CURAND.RNG, T::Random.BitFloatType) =
101101

102102
# perhaps minor type-piracy, but this lets us simulate into a CuArray using the
103103
# CPU random number generator
104-
Random.randn!(rng::MersenneTwister, A::CuArray{T}) where {T} =
105-
(A .= adapt(CuArray{T}, randn!(rng, adapt(Array{T},A))))
104+
Random.randn!(rng::MersenneTwister, A::CuArray) =
105+
(A .= adapt(CuArray, randn!(rng, adapt(Array, A))))
106106

107107
# CUDA makes some copies here as a workaround for JuliaGPU/CuArrays.jl#345 &
108108
# NVIDIA/cuFFT#2714055 but it doesn't appear to be needed in the R2C case, and

0 commit comments

Comments
 (0)