| { | |
| "name": "loop_006", | |
| "op_type": "loop_006", | |
| "description": "Compute the length of many long null-terminated strings", | |
| "tags": [ | |
| "simd-loop" | |
| ], | |
| "axes": { | |
| "N": { | |
| "type": "var", | |
| "description": "Buffer length (bytes)" | |
| } | |
| }, | |
| "inputs": { | |
| "p": { | |
| "shape": [ | |
| "N" | |
| ], | |
| "dtype": "uint8" | |
| } | |
| }, | |
| "outputs": { | |
| "checksum": { | |
| "shape": null, | |
| "dtype": "uint32", | |
| "description": "Scalar checksum" | |
| } | |
| }, | |
| "reference": "import numpy as np\n\ndef run(p):\n b = p; n = len(b); i = 0; res = 0\n while i < n:\n j = i\n while j < n and int(b[j]) != 0: j += 1\n length = j - i; i = j + 1\n res = (res + 1) & 0xffffffff\n res ^= ((length % 0xffff) << 16) & 0xffffffff\n res &= 0xffffffff\n return np.uint32(res)\n", | |
| "simd_loop_meta": { | |
| "output_inplace": false, | |
| "array_pad": 0, | |
| "scratch": [], | |
| "axes_order": [] | |
| } | |
| } | |