Skip to content

Commit 38108ba

Browse files
small fix
1 parent 1cef99a commit 38108ba

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/upsample.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function bilinear_upsample(x::AbstractArray{<:Number,4}, k::NTuple{2,Int})
2727
ihigh2_r = adjoint_of_idx(ilow2)[ihigh2]
2828

2929
@inbounds y = @view(x[ilow1,ilow2,:,:]) .* (1 .- wdiff1) .+ @view(x[ihigh1,ilow2,:,:]) .* wdiff1
30-
@inbounds y = y .* (1 .- wdiff2) .+ @view(y[:,ihigh2_r,:,:]) .* wdiff2
30+
@inbounds y .= y .* (1 .- wdiff2) .+ y[:,ihigh2_r,:,:] .* wdiff2
31+
# @inbounds y = y .* (1 .- wdiff2) .+ @view(y[:,ihigh2_r,:,:]) .* wdiff2 # equivalent to line above
3132
return y
3233
end
3334

@@ -100,23 +101,22 @@ which have been corrected for manually.
100101
"""
101102
function ∇bilinear_upsample::AbstractArray{<:Number, 4}, k::NTuple{2,Int})
102103
# This function is gpu friendly
103-
104+
105+
# Be more efficient on some corner cases
104106
if size(Δ, 1) == k[1]
105107
Δ = sum(Δ, dims=1)
106108
k = (1, k[2])
107109
end
108-
109110
if size(Δ, 2) == k[2]
110111
Δ = sum(Δ, dims=2)
111112
k = (k[1], 1)
112113
end
113-
114-
if (size(Δ, 1) == 1) & (size(Δ, 2) == 1)
114+
if (size(Δ, 1) == 1) && (size(Δ, 2) == 1)
115115
dx = Δ
116116
return dx
117117
end
118118

119-
n_chan, n_batch = size(Δ,3), size(Δ,4)
119+
n_chan, n_batch = size(Δ, 3), size(Δ, 4)
120120

121121
kern1 = get_downsamplekernel(k[1])
122122
kern2 = get_downsamplekernel(k[2])

0 commit comments

Comments
 (0)