File size: 1,066 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
38
39
40
41
42
43
44
45
{
  "name": "loop_101",
  "op_type": "loop_101",
  "description": "Upscale a pixel buffer by splitting each element into its high and low halves",
  "tags": [
    "simd-loop"
  ],
  "axes": {
    "n": {
      "type": "var",
      "description": "axis n"
    },
    "out_len": {
      "type": "var",
      "description": "axis out_len"
    }
  },
  "inputs": {
    "b": {
      "shape": [
        "n"
      ],
      "dtype": "uint8"
    }
  },
  "outputs": {
    "a": {
      "shape": [
        "out_len"
      ],
      "dtype": "uint8",
      "description": "Output array"
    }
  },
  "reference": "import numpy as np\n\ndef run(b):\n    n = b.shape[0]\n    a = np.zeros(2 * (n - 1), dtype=np.uint8)\n    if n >= 2:\n        s1 = b[:-1].astype(np.uint16)\n        s2 = b[1:].astype(np.uint16)\n        a[0::2] = ((3 * s1 + s2 + 2) >> 2).astype(np.uint8)\n        a[1::2] = ((3 * s2 + s1 + 2) >> 2).astype(np.uint8)\n    return a\n",
  "simd_loop_meta": {
    "output_inplace": false,
    "array_pad": 0,
    "scratch": [],
    "axes_order": [
      "n"
    ]
  }
}