Skip to content

Commit 7cc9524

Browse files
committed
Fixes
1 parent 97fb365 commit 7cc9524

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

src/upsample.jl

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ end
388388
@uniform in_width::UInt32, channels::UInt32, batch::UInt32 = size(x)
389389
@uniform out_width::UInt32 = size(y, 1)
390390
c::UInt32, n::UInt32 = @index(Global, NTuple)
391-
@inbounds for i in UnitRange{UInt32}(1, out_width)
392-
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, in_width)
391+
@inbounds for i in UnitRange{UInt32}(one(UInt32), out_width)
392+
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, in_width)
393393
y[i, c, n] = w0lambda * x[iw0, c, n] + w1lambda * x[iw1, c, n]
394394
end
395395
end
@@ -400,8 +400,8 @@ end
400400
@uniform in_width::UInt32, channels::UInt32, batch::UInt32 = size(Δ)
401401
@uniform out_width::UInt32 = size(dx, 1)
402402
c::UInt32, n::UInt32 = @index(Global, NTuple)
403-
@inbounds for i in UnitRange{UInt32}(1, in_width)
404-
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, out_width)
403+
@inbounds for i in UnitRange{UInt32}(one(UInt32), in_width)
404+
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, out_width)
405405
val = Δ[i, c, n]
406406
dx[ow0, c, n] += w0lambda * val
407407
dx[ow1, c, n] += w1lambda * val
@@ -416,8 +416,8 @@ end
416416
}
417417
@uniform in_width::UInt32, channels::UInt32, batch::UInt32 = size(x)
418418
i::UInt32 = @index(Global)
419-
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, in_width)
420-
@inbounds for n in 1:batch, c in 1:channels
419+
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, in_width)
420+
@inbounds for n in UnitRange{UInt32}(one(UInt32), batch), c in UnitRange{UInt32}(one(UInt32), channels)
421421
y[i, c, n] = w0lambda * x[iw0, c, n] + w1lambda * x[iw1, c, n]
422422
end
423423
end
@@ -428,8 +428,8 @@ end
428428
@uniform in_width::UInt32, channels::UInt32, batch::UInt32 = size(Δ)
429429
@uniform out_width::UInt32 = size(dx, 1)
430430
i::UInt32 = @index(Global)
431-
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, out_width)
432-
@inbounds for n in 1:batch, c in 1:channels
431+
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, out_width)
432+
@inbounds for n in UnitRange{UInt32}(one(UInt32), batch), c in UnitRange{UInt32}(one(UInt32), channels)
433433
val = Δ[i, c, n]
434434
@atomic dx[ow0, c, n] += w0lambda * val
435435
@atomic dx[ow1, c, n] += w1lambda * val
@@ -444,10 +444,10 @@ end
444444
@uniform in_width::UInt32, in_height::UInt32, channels::UInt32, batch::UInt32 = size(x)
445445
@uniform out_width::UInt32, out_height::UInt32 = size(y)[1:2]
446446
c::UInt32, n::UInt32 = @index(Global, NTuple)
447-
for j in UnitRange{UInt32}(1, out_height)
448-
ih0, ih1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - 0x1, align, in_height)
449-
for i in UnitRange{UInt32}(1, out_width)
450-
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, in_width)
447+
for j in UnitRange{UInt32}(one(UInt32), out_height)
448+
ih0, ih1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - one(UInt32), align, in_height)
449+
for i in UnitRange{UInt32}(one(UInt32), out_width)
450+
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, in_width)
451451
@inbounds y[i, j, c, n] =
452452
h0lambda * (w0lambda * x[iw0, ih0, c, n] + w1lambda * x[iw1, ih0, c, n]) +
453453
h1lambda * (w0lambda * x[iw0, ih1, c, n] + w1lambda * x[iw1, ih1, c, n])
@@ -461,10 +461,10 @@ end
461461
@uniform in_width::UInt32, in_height::UInt32, channels::UInt32, batch::UInt32 = size(Δ)
462462
@uniform out_width::UInt32, out_height::UInt32 = size(dx)[1:2]
463463
c::UInt32, n::UInt32 = @index(Global, NTuple)
464-
for j in UnitRange{UInt32}(1, in_height)
465-
oh0, oh1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - 0x1, align, out_height)
466-
for i in UnitRange{UInt32}(1, in_width)
467-
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, out_width)
464+
for j in UnitRange{UInt32}(one(UInt32), in_height)
465+
oh0, oh1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - one(UInt32), align, out_height)
466+
for i in UnitRange{UInt32}(one(UInt32), in_width)
467+
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, out_width)
468468
val = Δ[i, j, c, n]
469469
dx[ow0, oh0, c, n] += w0lambda * h0lambda * val
470470
dx[ow1, oh0, c, n] += w1lambda * h0lambda * val
@@ -481,9 +481,9 @@ end
481481
}
482482
@uniform in_width::UInt32, in_height::UInt32, channels::UInt32, batch::UInt32 = size(x)
483483
i::UInt32, j::UInt32 = @index(Global, NTuple)
484-
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, in_width)
485-
ih0, ih1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - 0x1, align, in_height)
486-
@inbounds for n in 1:batch, c in 1:channels
484+
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, in_width)
485+
ih0, ih1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - one(UInt32), align, in_height)
486+
@inbounds for n in UnitRange{UInt32}(one(UInt32), batch), c in UnitRange{UInt32}(one(UInt32), channels)
487487
y[i, j, c, n] =
488488
h0lambda * (w0lambda * x[iw0, ih0, c, n] + w1lambda * x[iw1, ih0, c, n]) +
489489
h1lambda * (w0lambda * x[iw0, ih1, c, n] + w1lambda * x[iw1, ih1, c, n])
@@ -496,9 +496,9 @@ end
496496
@uniform in_width::UInt32, in_height::UInt32, channels::UInt32, batch::UInt32 = size(Δ)
497497
@uniform out_width::UInt32, out_height::UInt32 = size(dx)[1:2]
498498
i::UInt32, j::UInt32 = @index(Global, NTuple)
499-
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, out_width)
500-
oh0, oh1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - 0x1, align, out_height)
501-
@inbounds for n in 1:batch, c in 1:channels
499+
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, out_width)
500+
oh0, oh1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - one(UInt32), align, out_height)
501+
@inbounds for n in UnitRange{UInt32}(one(UInt32), batch), c in UnitRange{UInt32}(one(UInt32), channels)
502502
val = Δ[i, j, c, n]
503503
@atomic dx[ow0, oh0, c, n] += w0lambda * h0lambda * val
504504
@atomic dx[ow1, oh0, c, n] += w1lambda * h0lambda * val
@@ -516,12 +516,12 @@ end
516516
@uniform channels::UInt32, batch::UInt32 = size(x, 4), size(x, 5)
517517
@uniform out_width::UInt32, out_height::UInt32, out_depth::UInt32 = size(y)[1:3]
518518
c::UInt32, n::UInt32 = @index(Global, NTuple)
519-
for k in UnitRange{UInt32}(1, out_depth)
520-
id0, id1, d0lambda, d1lambda = source_index_and_lambda(rdepth, k - 0x1, align, in_depth)
521-
for j in UnitRange{UInt32}(1, out_height)
522-
ih0, ih1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - 0x1, align, in_height)
523-
for i in UnitRange{UInt32}(1, out_width)
524-
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, in_width)
519+
for k in UnitRange{UInt32}(one(UInt32), out_depth)
520+
id0, id1, d0lambda, d1lambda = source_index_and_lambda(rdepth, k - one(UInt32), align, in_depth)
521+
for j in UnitRange{UInt32}(one(UInt32), out_height)
522+
ih0, ih1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - one(UInt32), align, in_height)
523+
for i in UnitRange{UInt32}(one(UInt32), out_width)
524+
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, in_width)
525525
@inbounds y[i, j, k, c, n] =
526526
d0lambda * (
527527
h0lambda * (w0lambda * x[iw0, ih0, id0, c, n] + w1lambda * x[iw1, ih0, id0, c, n]) +
@@ -541,12 +541,12 @@ end
541541
@uniform channels::UInt32, batch::UInt32 = size(Δ, 4), size(Δ, 5)
542542
@uniform out_width::UInt32, out_height::UInt32, out_depth::UInt32 = size(dx)[1:3]
543543
c::UInt32, n::UInt32 = @index(Global, NTuple)
544-
for k in UnitRange{UInt32}(1, in_depth)
545-
od0, od1, d0lambda, d1lambda = source_index_and_lambda(rdepth, k - 0x1, align, out_depth)
546-
for j in UnitRange{UInt32}(1, in_height)
547-
oh0, oh1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - 0x1, align, out_height)
548-
@inbounds for i in UnitRange{UInt32}(1, in_width)
549-
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, out_width)
544+
for k in UnitRange{UInt32}(one(UInt32), in_depth)
545+
od0, od1, d0lambda, d1lambda = source_index_and_lambda(rdepth, k - one(UInt32), align, out_depth)
546+
for j in UnitRange{UInt32}(one(UInt32), in_height)
547+
oh0, oh1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - one(UInt32), align, out_height)
548+
@inbounds for i in UnitRange{UInt32}(one(UInt32), in_width)
549+
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, out_width)
550550
val = Δ[i, j, k, c, n]
551551
dx[ow0, oh0, od0, c, n] += w0lambda * h0lambda * d0lambda * val
552552
dx[ow1, oh0, od0, c, n] += w1lambda * h0lambda * d0lambda * val
@@ -570,10 +570,10 @@ end
570570
@uniform in_width::UInt32, in_height::UInt32, in_depth::UInt32 = size(x)[1:3]
571571
@uniform channels::UInt32, batch::UInt32 = size(x, 4), size(x, 5)
572572
i::UInt32, j::UInt32, k::UInt32 = @index(Global, NTuple)
573-
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, in_width)
574-
ih0, ih1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - 0x1, align, in_height)
575-
id0, id1, d0lambda, d1lambda = source_index_and_lambda(rdepth, k - 0x1, align, in_depth)
576-
@inbounds for n in 1:batch, c in 1:channels
573+
iw0, iw1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, in_width)
574+
ih0, ih1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - one(UInt32), align, in_height)
575+
id0, id1, d0lambda, d1lambda = source_index_and_lambda(rdepth, k - one(UInt32), align, in_depth)
576+
@inbounds for n in UnitRange{UInt32}(one(UInt32), batch), c in UnitRange{UInt32}(one(UInt32), channels)
577577
y[i, j, k, c, n] =
578578
d0lambda * (
579579
h0lambda * (w0lambda * x[iw0, ih0, id0, c, n] + w1lambda * x[iw1, ih0, id0, c, n]) +
@@ -591,10 +591,10 @@ end
591591
@uniform channels::UInt32, batch::UInt32 = size(Δ, 4), size(Δ, 5)
592592
@uniform out_width::UInt32, out_height::UInt32, out_depth::UInt32 = size(dx)[1:3]
593593
i::UInt32, j::UInt32, k::UInt32 = @index(Global, NTuple)
594-
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - 0x1, align, out_width)
595-
oh0, oh1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - 0x1, align, out_height)
596-
od0, od1, d0lambda, d1lambda = source_index_and_lambda(rdepth, k - 0x1, align, out_depth)
597-
@inbounds for n in 1:batch, c in 1:channels
594+
ow0, ow1, w0lambda, w1lambda = source_index_and_lambda(rwidth, i - one(UInt32), align, out_width)
595+
oh0, oh1, h0lambda, h1lambda = source_index_and_lambda(rheight, j - one(UInt32), align, out_height)
596+
od0, od1, d0lambda, d1lambda = source_index_and_lambda(rdepth, k - one(UInt32), align, out_depth)
597+
@inbounds for n in UnitRange{UInt32}(one(UInt32), batch), c in UnitRange{UInt32}(one(UInt32), channels)
598598
val = Δ[i, j, k, c, n]
599599
@atomic dx[ow0, oh0, od0, c, n] += w0lambda * h0lambda * d0lambda * val
600600
@atomic dx[ow1, oh0, od0, c, n] += w1lambda * h0lambda * d0lambda * val
@@ -616,10 +616,10 @@ end
616616
max(zero(T), ratio * (out_idx + T(0.5)) - T(0.5))
617617

618618
iw0 = floor(UInt32, real_index)
619-
offset::UInt32 = ifelse(iw0 < in_width - 0x1, 0x1, 0x0)
620-
iw1 = iw0 + offset + 0x1
619+
offset::UInt32 = ifelse(iw0 < in_width - one(UInt32), one(UInt32), zero(UInt32))
620+
iw1 = iw0 + offset + one(UInt32)
621621

622622
w1lambda = real_index - iw0
623623
w0lambda = T(1) - w1lambda
624-
return iw0 + 0x1, iw1, w0lambda, w1lambda
624+
return iw0 + one(UInt32), iw1, w0lambda, w1lambda
625625
end

0 commit comments

Comments
 (0)