388
388
@uniform in_width:: UInt32 , channels:: UInt32 , batch:: UInt32 = size (x)
389
389
@uniform out_width:: UInt32 = size (y, 1 )
390
390
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)
393
393
y[i, c, n] = w0lambda * x[iw0, c, n] + w1lambda * x[iw1, c, n]
394
394
end
395
395
end
400
400
@uniform in_width:: UInt32 , channels:: UInt32 , batch:: UInt32 = size (Δ)
401
401
@uniform out_width:: UInt32 = size (dx, 1 )
402
402
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)
405
405
val = Δ[i, c, n]
406
406
dx[ow0, c, n] += w0lambda * val
407
407
dx[ow1, c, n] += w1lambda * val
416
416
}
417
417
@uniform in_width:: UInt32 , channels:: UInt32 , batch:: UInt32 = size (x)
418
418
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)
421
421
y[i, c, n] = w0lambda * x[iw0, c, n] + w1lambda * x[iw1, c, n]
422
422
end
423
423
end
428
428
@uniform in_width:: UInt32 , channels:: UInt32 , batch:: UInt32 = size (Δ)
429
429
@uniform out_width:: UInt32 = size (dx, 1 )
430
430
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)
433
433
val = Δ[i, c, n]
434
434
@atomic dx[ow0, c, n] += w0lambda * val
435
435
@atomic dx[ow1, c, n] += w1lambda * val
@@ -444,10 +444,10 @@ end
444
444
@uniform in_width:: UInt32 , in_height:: UInt32 , channels:: UInt32 , batch:: UInt32 = size (x)
445
445
@uniform out_width:: UInt32 , out_height:: UInt32 = size (y)[1 : 2 ]
446
446
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)
451
451
@inbounds y[i, j, c, n] =
452
452
h0lambda * (w0lambda * x[iw0, ih0, c, n] + w1lambda * x[iw1, ih0, c, n]) +
453
453
h1lambda * (w0lambda * x[iw0, ih1, c, n] + w1lambda * x[iw1, ih1, c, n])
@@ -461,10 +461,10 @@ end
461
461
@uniform in_width:: UInt32 , in_height:: UInt32 , channels:: UInt32 , batch:: UInt32 = size (Δ)
462
462
@uniform out_width:: UInt32 , out_height:: UInt32 = size (dx)[1 : 2 ]
463
463
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)
468
468
val = Δ[i, j, c, n]
469
469
dx[ow0, oh0, c, n] += w0lambda * h0lambda * val
470
470
dx[ow1, oh0, c, n] += w1lambda * h0lambda * val
481
481
}
482
482
@uniform in_width:: UInt32 , in_height:: UInt32 , channels:: UInt32 , batch:: UInt32 = size (x)
483
483
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)
487
487
y[i, j, c, n] =
488
488
h0lambda * (w0lambda * x[iw0, ih0, c, n] + w1lambda * x[iw1, ih0, c, n]) +
489
489
h1lambda * (w0lambda * x[iw0, ih1, c, n] + w1lambda * x[iw1, ih1, c, n])
496
496
@uniform in_width:: UInt32 , in_height:: UInt32 , channels:: UInt32 , batch:: UInt32 = size (Δ)
497
497
@uniform out_width:: UInt32 , out_height:: UInt32 = size (dx)[1 : 2 ]
498
498
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)
502
502
val = Δ[i, j, c, n]
503
503
@atomic dx[ow0, oh0, c, n] += w0lambda * h0lambda * val
504
504
@atomic dx[ow1, oh0, c, n] += w1lambda * h0lambda * val
@@ -516,12 +516,12 @@ end
516
516
@uniform channels:: UInt32 , batch:: UInt32 = size (x, 4 ), size (x, 5 )
517
517
@uniform out_width:: UInt32 , out_height:: UInt32 , out_depth:: UInt32 = size (y)[1 : 3 ]
518
518
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)
525
525
@inbounds y[i, j, k, c, n] =
526
526
d0lambda * (
527
527
h0lambda * (w0lambda * x[iw0, ih0, id0, c, n] + w1lambda * x[iw1, ih0, id0, c, n]) +
@@ -541,12 +541,12 @@ end
541
541
@uniform channels:: UInt32 , batch:: UInt32 = size (Δ, 4 ), size (Δ, 5 )
542
542
@uniform out_width:: UInt32 , out_height:: UInt32 , out_depth:: UInt32 = size (dx)[1 : 3 ]
543
543
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)
550
550
val = Δ[i, j, k, c, n]
551
551
dx[ow0, oh0, od0, c, n] += w0lambda * h0lambda * d0lambda * val
552
552
dx[ow1, oh0, od0, c, n] += w1lambda * h0lambda * d0lambda * val
@@ -570,10 +570,10 @@ end
570
570
@uniform in_width:: UInt32 , in_height:: UInt32 , in_depth:: UInt32 = size (x)[1 : 3 ]
571
571
@uniform channels:: UInt32 , batch:: UInt32 = size (x, 4 ), size (x, 5 )
572
572
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)
577
577
y[i, j, k, c, n] =
578
578
d0lambda * (
579
579
h0lambda * (w0lambda * x[iw0, ih0, id0, c, n] + w1lambda * x[iw1, ih0, id0, c, n]) +
@@ -591,10 +591,10 @@ end
591
591
@uniform channels:: UInt32 , batch:: UInt32 = size (Δ, 4 ), size (Δ, 5 )
592
592
@uniform out_width:: UInt32 , out_height:: UInt32 , out_depth:: UInt32 = size (dx)[1 : 3 ]
593
593
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)
598
598
val = Δ[i, j, k, c, n]
599
599
@atomic dx[ow0, oh0, od0, c, n] += w0lambda * h0lambda * d0lambda * val
600
600
@atomic dx[ow1, oh0, od0, c, n] += w1lambda * h0lambda * d0lambda * val
@@ -616,10 +616,10 @@ end
616
616
max (zero (T), ratio * (out_idx + T (0.5 )) - T (0.5 ))
617
617
618
618
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)
621
621
622
622
w1lambda = real_index - iw0
623
623
w0lambda = T (1 ) - w1lambda
624
- return iw0 + 0x1 , iw1, w0lambda, w1lambda
624
+ return iw0 + one (UInt32) , iw1, w0lambda, w1lambda
625
625
end
0 commit comments