awu12's picture
Replace pre-PR#15 conv2d-only trace with current simd-loop set (definitions + workloads + reference/autovec solutions)
f25167e verified
Raw
History Blame Contribute Delete
1.62 kB
{
"name": "loop_106",
"op_type": "loop_106",
"description": "Partition a vector by bit flag, concentrating set-bit elements to one side",
"tags": [
"simd-loop"
],
"axes": {
"n": {
"type": "var",
"description": "axis n"
}
},
"inputs": {
"a": {
"shape": [
"n"
],
"dtype": "uint32"
}
},
"outputs": {
"b": {
"shape": [
"n"
],
"dtype": "uint32",
"description": "Output array"
}
},
"reference": "import numpy as np\n\n_M = 0xFFFFFFFF\n\ndef _popcount(x):\n return bin(x & _M).count('1')\n\ndef _compress(x, m):\n x &= m\n mk = (~m << 1) & _M\n for i in range(5):\n mp = (mk ^ (mk << 1)) & _M\n mp = (mp ^ (mp << 2)) & _M\n mp = (mp ^ (mp << 4)) & _M\n mp = (mp ^ (mp << 8)) & _M\n mp = (mp ^ (mp << 16)) & _M\n mv = mp & m\n m = (m ^ mv) | (mv >> (1 << i))\n t = x & mv\n x = (x ^ t) | (t >> (1 << i))\n mk &= (~mp) & _M\n return x & _M\n\ndef _sag(x, m):\n return (((_compress(x, m) << _popcount(m)) & _M) | _compress(x, (~m) & _M)) & _M\n\n_PC = [0xaaaaaaaa, 0xcccccccc, 0x0f0f0f0f, 0x0ff00ff0, 0x0ffff000]\n_P = [_PC[0], _sag(_PC[1], _PC[0]), _sag(_PC[2], _PC[0]),\n _sag(_PC[3], _PC[0]), _sag(_PC[4], _PC[0])]\n\ndef _permute(x):\n for pi in _P:\n x = _sag(x, pi)\n return x\n\ndef run(a):\n return np.array([_permute(int(v)) for v in a], dtype=np.uint32)\n",
"simd_loop_meta": {
"output_inplace": false,
"array_pad": 0,
"scratch": [],
"axes_order": [
"n"
]
}
}