Fix writing past end in i16 transpose with overlapped halves
This commit is contained in:
parent
8ff40cb2e5
commit
61eefe0776
@ -85,6 +85,8 @@ fn transpose{T, k, kh}(r0:*void, x0:*void, w:u64, h:u64) : void = {
|
|||||||
# Effective height: number of rows read, counting overlap twice
|
# Effective height: number of rows read, counting overlap twice
|
||||||
# Just use base transpose for short overhang; otherwise round up
|
# Just use base transpose for short overhang; otherwise round up
|
||||||
he := h; if (use_overlap{ho}) he += k - ho
|
he := h; if (use_overlap{ho}) he += k - ho
|
||||||
|
def has_half = 2*k == kh
|
||||||
|
if (has_half and he==kh and h<he) he = k # Skip main loop; caught with he<h tests later
|
||||||
# Main transpose
|
# Main transpose
|
||||||
hm := h - kh
|
hm := h - kh
|
||||||
@for_mult{kh} (y0 to he) { y:=y0; if (y>hm) y = hm
|
@for_mult{kh} (y0 to he) { y:=y0; if (y>hm) y = hm
|
||||||
@ -92,12 +94,15 @@ fn transpose{T, k, kh}(r0:*void, x0:*void, w:u64, h:u64) : void = {
|
|||||||
kernel{...at{x,y}, k, kh, w, h}
|
kernel{...at{x,y}, k, kh, w, h}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Half-row for non-square i16 case
|
# Half-row(s) for non-square i16 case
|
||||||
if (2*k == kh and (he & k) != 0) {
|
if (has_half and (he & k) != 0) {
|
||||||
e := h%kh; if (e<k) e = k
|
n := 1 + cast_i{u64, he < h} # 2 for overlapped halves
|
||||||
y := h - e
|
e := h%kh; if (he<h or e<k) e = k
|
||||||
@for_mult{k} (x to w) {
|
@for (yi to n) {
|
||||||
kernel{...at{x,y}, k, k, w, h}
|
y:u64 = 0; if (yi == n-1) y = h - e
|
||||||
|
@for_mult{k} (x to w) {
|
||||||
|
kernel{...at{x,y}, k, k, w, h}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Base transpose used if overlap wasn't
|
# Base transpose used if overlap wasn't
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user