You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionupsample_linear_wcn!(output::AbstractArray{T,3}, input::AbstractArray{T,3}) where T
150
150
size(input)[2:3] ==size(output)[2:3] ||error("Number of input and output channels and batches must match. Got input $(size(input)) and output $(size(output))")
151
151
in_w, channels, batches =size(input)
152
+
RT =real(T)
152
153
# treat batch and channel dimension as one for better parallelization granularity
153
154
channels *= batches
154
155
out_w, _, _ =size(output)
155
156
output_slice_size = out_w
156
157
157
-
# T() and // so that we can handle rationals (super slow)
158
-
width_scale =T((in_w -1) // (out_w -1))
158
+
#real(T)() and // so that we can handle rationals (super slow)
159
+
width_scale =RT((in_w -1) // (out_w -1))
159
160
160
161
@inlineidx(c, w) = c * in_w + w +1
161
162
@@ -175,14 +176,15 @@ end
175
176
functionupsample_bilinear_whcn!(output::AbstractArray{T,4}, input::AbstractArray{T,4}) where T
176
177
size(input)[3:4] ==size(output)[3:4] ||error("Number of input and output channels and batches must match. Got input $(size(input)) and output $(size(output))")
177
178
in_w, in_h, channels, batches =size(input)
179
+
RT =real(T)
178
180
# treat batch and channel dimension as one for better parallelization granularity
179
181
channels *= batches
180
182
out_w, out_h, _, _ =size(output)
181
183
output_slice_size = out_h * out_w
182
184
183
-
# T() and // so that we can handle rationals (super slow)
184
-
width_scale =T((in_w -1) // (out_w -1))
185
-
height_scale =T((in_h -1) // (out_h -1))
185
+
#real(T)() and // so that we can handle rationals (super slow)
186
+
width_scale =RT((in_w -1) // (out_w -1))
187
+
height_scale =RT((in_h -1) // (out_h -1))
186
188
187
189
@inlineidx(c, h, w) = c * in_h * in_w + h * in_w + w +1
188
190
@@ -208,15 +210,16 @@ end
208
210
functionupsample_trilinear_whdcn!(output::AbstractArray{T,5}, input::AbstractArray{T,5}) where T
209
211
size(input)[4:5] ==size(output)[4:5] ||error("Number of input and output channels and batches must match. Got input $(size(input)) and output $(size(output))")
210
212
in_w, in_h, in_d, channels, batches =size(input)
213
+
RT =real(T)
211
214
# treat batch and channel dimension as one for better parallelization granularity
212
215
channels *= batches
213
216
out_w, out_h, out_d, _, _ =size(output)
214
217
output_slice_size = out_h * out_w * out_d
215
218
216
-
# T() and // so that we can handle rationals (super slow)
217
-
width_scale =T((in_w -1) // (out_w -1))
218
-
height_scale =T((in_h -1) // (out_h -1))
219
-
depth_scale =T((in_d -1) // (out_d -1))
219
+
#real(T)() and // so that we can handle rationals (super slow)
220
+
width_scale =RT((in_w -1) // (out_w -1))
221
+
height_scale =RT((in_h -1) // (out_h -1))
222
+
depth_scale =RT((in_d -1) // (out_d -1))
220
223
221
224
@inlineidx(c, d, h, w) = c * in_d * in_h * in_w + d * in_h * in_w + h * in_w + w +1
222
225
@@ -268,13 +271,13 @@ end
268
271
function∇upsample_linear_wcn!(dx::AbstractArray{T,3}, Δ::AbstractArray{T,3}) where T
269
272
size(dx)[2:3] ==size(Δ)[2:3] ||error("Number of input and output channels and batches must match. Got input $(size(input)) and output $(size(output))")
270
273
in_w, channels, batches =size(dx)
271
-
274
+
RT =real(T)
272
275
# treat batch and channel dimension as one for better parallelization granularity
273
276
channels *= batches
274
277
out_w, _, _ =size(Δ)
275
278
output_slice_size = out_w
276
279
277
-
width_scale =T((in_w -1) // (out_w -1))
280
+
width_scale =RT((in_w -1) // (out_w -1))
278
281
279
282
@inlineidx(c, w) = c * in_w + w +1
280
283
@@ -294,14 +297,14 @@ end
294
297
function∇upsample_bilinear_whcn!(dx::AbstractArray{T,4}, Δ::AbstractArray{T,4}) where T
295
298
size(dx)[3:4] ==size(Δ)[3:4] ||error("Number of input and output channels and batches must match. Got input $(size(input)) and output $(size(output))")
296
299
in_w, in_h, channels, batches =size(dx)
297
-
300
+
RT =real(T)
298
301
# treat batch and channel dimension as one for better parallelization granularity
299
302
channels *= batches
300
303
out_w, out_h, _, _ =size(Δ)
301
304
output_slice_size = out_h * out_w
302
305
303
-
width_scale =T((in_w -1) // (out_w -1))
304
-
height_scale =T((in_h -1) // (out_h -1))
306
+
width_scale =RT((in_w -1) // (out_w -1))
307
+
height_scale =RT((in_h -1) // (out_h -1))
305
308
306
309
@inlineidx(c, h, w) = c * in_h * in_w + h * in_w + w +1
307
310
@@ -326,15 +329,16 @@ end
326
329
function∇upsample_trilinear_whdcn!(dx::AbstractArray{T,5}, Δ::AbstractArray{T,5}) where T
327
330
size(dx)[4:5] ==size(Δ)[4:5] ||error("Number of input and output channels and batches must match. Got dx $(size(dx)) and Δ $(size(Δ))")
328
331
in_w, in_h, in_d, channels, batches =size(dx)
332
+
RT =real(T)
329
333
# treat batch and channel dimension as one for better parallelization granularity
330
334
channels *= batches
331
335
out_w, out_h, out_d, _, _ =size(Δ)
332
336
output_slice_size = out_h * out_w * out_d
333
337
334
-
# T() and // so that we can handle rationals (super slow)
335
-
width_scale =T((in_w -1) // (out_w -1))
336
-
height_scale =T((in_h -1) // (out_h -1))
337
-
depth_scale =T((in_d -1) // (out_d -1))
338
+
#real(T)() and // so that we can handle rationals (super slow)
339
+
width_scale =RT((in_w -1) // (out_w -1))
340
+
height_scale =RT((in_h -1) // (out_h -1))
341
+
depth_scale =RT((in_d -1) // (out_d -1))
338
342
339
343
@inlineidx(c, d, h, w) = c * in_d * in_h * in_w + d * in_h * in_w + h * in_w + w +1
0 commit comments