Separate transpose el_B case and fix dropped fill for shape 2‿n
This commit is contained in:
parent
dea063cb7b
commit
968bfd2fc6
@ -60,8 +60,7 @@ B transp_c1(B t, B x) {
|
|||||||
usz ia = IA(x);
|
usz ia = IA(x);
|
||||||
usz* xsh = SH(x);
|
usz* xsh = SH(x);
|
||||||
usz h = xsh[0];
|
usz h = xsh[0];
|
||||||
if (ia==0 || h==1) {
|
if (ia==0 || h==1 || h==ia /*w==1*/) {
|
||||||
no_reorder:;
|
|
||||||
Arr* r = cpyWithShape(x);
|
Arr* r = cpyWithShape(x);
|
||||||
ShArr* sh = m_shArr(xr);
|
ShArr* sh = m_shArr(xr);
|
||||||
shcpy(sh->a, xsh+1, xr-1);
|
shcpy(sh->a, xsh+1, xr-1);
|
||||||
@ -70,21 +69,34 @@ B transp_c1(B t, B x) {
|
|||||||
return taga(r);
|
return taga(r);
|
||||||
}
|
}
|
||||||
usz w = xsh[1] * shProd(xsh, 2, xr);
|
usz w = xsh[1] * shProd(xsh, 2, xr);
|
||||||
if (w==1) goto no_reorder;
|
|
||||||
|
|
||||||
Arr* r;
|
Arr* r;
|
||||||
usz xi = 0;
|
usz xi = 0;
|
||||||
u8 xe = TI(x,elType);
|
u8 xe = TI(x,elType);
|
||||||
bool toBit = false;
|
bool toBit = false;
|
||||||
if (h==2) {
|
|
||||||
if (xe==el_B) {
|
if (xe==el_B) {
|
||||||
|
B xf = getFillR(x);
|
||||||
B* xp = TO_BPTR(x);
|
B* xp = TO_BPTR(x);
|
||||||
|
|
||||||
|
HArr_p p = m_harrUp(ia);
|
||||||
|
if (h==2) {
|
||||||
B* x0 = xp; B* x1 = x0+w;
|
B* x0 = xp; B* x1 = x0+w;
|
||||||
HArr_p rp = m_harrUp(ia);
|
for (usz i=0; i<w; i++) { p.a[i*2] = inc(x0[i]); p.a[i*2+1] = inc(x1[i]); }
|
||||||
for (usz i=0; i<w; i++) { rp.a[i*2] = inc(x0[i]); rp.a[i*2+1] = inc(x1[i]); }
|
|
||||||
NOGC_E;
|
|
||||||
r = (Arr*) rp.c;
|
|
||||||
} else {
|
} else {
|
||||||
|
for(usz y=0;y<h;y++) for(usz x=0;x<w;x++) p.a[x*h+y] = inc(xp[xi++]); // TODO inc afterwards, but don't when there's a method of freeing a HArr without freeing its elements
|
||||||
|
}
|
||||||
|
NOGC_E;
|
||||||
|
|
||||||
|
usz* rsh = arr_shAlloc((Arr*)p.c, xr);
|
||||||
|
if (xr==2) {
|
||||||
|
rsh[0] = w;
|
||||||
|
rsh[1] = h;
|
||||||
|
} else {
|
||||||
|
shcpy(rsh, xsh+1, xr-1);
|
||||||
|
rsh[xr-1] = h;
|
||||||
|
}
|
||||||
|
decG(x); return qWithFill(p.b, xf);
|
||||||
|
} else if (h==2) {
|
||||||
#ifndef __BMI2__
|
#ifndef __BMI2__
|
||||||
if (xe==el_bit) { x = taga(cpyI8Arr(x)); xsh=SH(x); xe=el_i8; toBit=true; }
|
if (xe==el_bit) { x = taga(cpyI8Arr(x)); xsh=SH(x); xe=el_i8; toBit=true; }
|
||||||
void* rp = m_tyarrp(&r,elWidth(xe),ia,el2t(xe));
|
void* rp = m_tyarrp(&r,elWidth(xe),ia,el2t(xe));
|
||||||
@ -107,8 +119,7 @@ B transp_c1(B t, B x) {
|
|||||||
case el_i32:case el_c32: { u32* x0=xp; u32* x1=x0+w; for (usz i=0; i<w; i++) { ((u32*)rp)[i*2] = x0[i]; ((u32*)rp)[i*2+1] = x1[i]; } } break;
|
case el_i32:case el_c32: { u32* x0=xp; u32* x1=x0+w; for (usz i=0; i<w; i++) { ((u32*)rp)[i*2] = x0[i]; ((u32*)rp)[i*2+1] = x1[i]; } } break;
|
||||||
case el_f64: { u64* x0=xp; u64* x1=x0+w; for (usz i=0; i<w; i++) { ((u64*)rp)[i*2] = x0[i]; ((u64*)rp)[i*2+1] = x1[i]; } } break;
|
case el_f64: { u64* x0=xp; u64* x1=x0+w; for (usz i=0; i<w; i++) { ((u64*)rp)[i*2] = x0[i]; ((u64*)rp)[i*2+1] = x1[i]; } } break;
|
||||||
}
|
}
|
||||||
}
|
} else if (w==2) {
|
||||||
} else if (w==2 && xe!=el_B) {
|
|
||||||
#ifndef __BMI2__
|
#ifndef __BMI2__
|
||||||
if (xe==el_bit) { x = taga(cpyI8Arr(x)); xsh=SH(x); xe=el_i8; toBit=true; }
|
if (xe==el_bit) { x = taga(cpyI8Arr(x)); xsh=SH(x); xe=el_i8; toBit=true; }
|
||||||
#endif
|
#endif
|
||||||
@ -139,24 +150,6 @@ B transp_c1(B t, B x) {
|
|||||||
case el_i16:case el_c16: { u16* xp=tyany_ptr(x); u16* rp = m_tyarrp(&r,2,ia,el2t(xe)); TRANSPOSE_SIMD(i16, rp, xp, w, h); break; }
|
case el_i16:case el_c16: { u16* xp=tyany_ptr(x); u16* rp = m_tyarrp(&r,2,ia,el2t(xe)); TRANSPOSE_SIMD(i16, rp, xp, w, h); break; }
|
||||||
case el_i32:case el_c32: { u32* xp=tyany_ptr(x); u32* rp = m_tyarrp(&r,4,ia,el2t(xe)); TRANSPOSE_SIMD(i32, rp, xp, w, h); break; }
|
case el_i32:case el_c32: { u32* xp=tyany_ptr(x); u32* rp = m_tyarrp(&r,4,ia,el2t(xe)); TRANSPOSE_SIMD(i32, rp, xp, w, h); break; }
|
||||||
case el_f64: { f64* xp=f64any_ptr(x); f64* rp; r=m_f64arrp(&rp,ia); TRANSPOSE_SIMD(i64, rp, xp, w, h); break; }
|
case el_f64: { f64* xp=f64any_ptr(x); f64* rp; r=m_f64arrp(&rp,ia); TRANSPOSE_SIMD(i64, rp, xp, w, h); break; }
|
||||||
case el_B: { // can't be bothered to implement a bitarr transpose
|
|
||||||
B xf = getFillR(x);
|
|
||||||
B* xp = TO_BPTR(x);
|
|
||||||
|
|
||||||
HArr_p p = m_harrUp(ia);
|
|
||||||
for(usz y=0;y<h;y++) for(usz x=0;x<w;x++) p.a[x*h+y] = inc(xp[xi++]); // TODO inc afterwards, but don't when there's a method of freeing a HArr without freeing its elements
|
|
||||||
NOGC_E;
|
|
||||||
|
|
||||||
usz* rsh = arr_shAlloc((Arr*)p.c, xr);
|
|
||||||
if (xr==2) {
|
|
||||||
rsh[0] = w;
|
|
||||||
rsh[1] = h;
|
|
||||||
} else {
|
|
||||||
shcpy(rsh, xsh+1, xr-1);
|
|
||||||
rsh[xr-1] = h;
|
|
||||||
}
|
|
||||||
decG(x); return qWithFill(p.b, xf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usz* rsh = arr_shAlloc(r, xr);
|
usz* rsh = arr_shAlloc(r, xr);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user