Skip to content

Commit a9ed869

Browse files
committed
force the computation on float32 type
Float32 type is faster on GPU than Float64 type. This also gives a 1.5x performance boost on CPU.
1 parent bfbaf69 commit a9ed869

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/models.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,18 @@ Mathematically, this function solves the following ROF model using the primal-du
7474
function solve_ROF_PD(img::AbstractArray, λ::Real, num_iters::Integer)
7575
# Total Variation regularized image denoising using the primal dual algorithm
7676
# Implement according to reference [1]
77-
τ = 1/4 # see 2nd remark after proof of Theorem 3.1.
7877

79-
g = of_eltype(floattype(eltype(img)), img) # use the same symbol in the paper
78+
# use Float32 for better GPU performance
79+
τ = Float32(1/4) # see 2nd remark after proof of Theorem 3.1.
80+
λ = Float32(λ)
81+
FT = float32(eltype(img))
82+
83+
# use the same symbol in the paper
84+
if FT == eltype(img)
85+
g = img
86+
else
87+
g = FT.(img)
88+
end
8089
u = similar(g)
8190
p = fgradient(g)
8291
div_p = similar(g)

0 commit comments

Comments
 (0)