File size: 2,505 Bytes
67f32d3
 
 
 
8a0c20e
 
67f32d3
8a0c20e
2f3e331
67f32d3
 
 
8a0c20e
67f32d3
 
 
 
2f3e331
8a0c20e
 
2f3e331
8a0c20e
 
67f32d3
8a0c20e
 
 
67f32d3
8a0c20e
 
 
 
 
67f32d3
8a0c20e
67f32d3
 
 
8a0c20e
67f32d3
 
 
 
8a0c20e
2f3e331
67f32d3
8a0c20e
 
 
67f32d3
8a0c20e
 
 
 
 
67f32d3
 
 
2f3e331
 
67f32d3
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
  "domain": "ai.onnx",
  "name": "Sign",
  "sinceVersion": 13,
  "inputs": { "input": { "dtype": "T" } },
  "outputs": { "output": { "dtype": "T", "rank": "ranks.input", "shape": "shapes.input" } },
  "typeConstraints": { "T": ["float32", "float16", "int32", "uint32", "int16", "int8", "uint8"] },
  "tunables": { "WORKGROUP_SIZE": { "default": 256 } },
  "derive": { "scalar": "dtypes.T" },
  "variants": [
    {
      "id": "same_layout_vec4",
      "priority": 20,
      "when": ["numel(shapes.input) > 0", "numel(shapes.input) % 4 == 0", "numel(shapes.input) == numel(shapes.output)", "f16Ok(dtypes.T)"],
      "passes": [
        {
          "id": "main",
          "name": "Sign.Vec4",
          "shader": "unary-vec4.wgsl.jinja",
          "derive": {
            "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"",
            "vec4PerThread": "4 if numel(shapes.output) * dtypeBytes(tensorDtypes.output) <= 16777216 else 1"
          },
          "bindings": [
            { "arg": "input", "name": "x", "elementType": "$vectorScalar" },
            { "arg": "output", "name": "y", "elementType": "$vectorScalar" },
            { "name": "params", "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.output) / 4" }] }
          ],
          "dispatch": {
            "x": "min(ceilDiv((ceilDiv(numel(shapes.output) / 4, 4 if numel(shapes.output) * dtypeBytes(tensorDtypes.output) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
            "y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.output) / 4, 4 if numel(shapes.output) * dtypeBytes(tensorDtypes.output) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)",
            "z": 1
          }
        }
      ]
    },
    {
      "id": "elementwise",
      "when": ["numel(shapes.input) == numel(shapes.output) and (f16Ok(dtypes.T))"],
      "passes": [
        {
          "id": "main",
          "name": "Sign",
          "shader": "unary-scalar.wgsl.jinja",
          "derive": { "itemsPerInvocation": 4 },
          "bindings": [
            "input",
            "output",
            { "name": "params", "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.output)" }] }
          ],
          "dispatch": {
            "x": "min(ceilDiv((ceilDiv(numel(shapes.output), 4)), (tunables.WORKGROUP_SIZE)), 65535)",
            "y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.output), 4)), (tunables.WORKGROUP_SIZE)), 65535)",
            "z": 1
          }
        }
      ]
    }
  ],
  "bindings": {}
}