File size: 958 Bytes
f25167e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{
  "name": "loop_005",
  "op_type": "loop_005",
  "description": "Compute the length of many short 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": []
  }
}