File size: 12,151 Bytes
0c553b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662da36
0c553b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662da36
0c553b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f2bf786
662da36
0c553b6
 
 
 
 
 
 
 
 
 
 
 
 
f2bf786
0c553b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662da36
0c553b6
 
 
 
 
 
 
 
 
 
 
662da36
0c553b6
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
{
  "cases": [
    {
      "name": "vector",
      "inputs": {
        "x": { "dtype": "float32", "shape": [32], "data": { "kind": "fillFloat32", "sinStep": 0.1, "cosStep": 0.2 } }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [32], "tolerance": 0.000001 } }
    },
    {
      "name": "rank0_scalar",
      "inputs": { "x": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [-1.25] } } },
      "outputs": { "y": { "dtype": "float32", "shape": [], "tolerance": 0.000001 } }
    },
    {
      "name": "saturation_and_special_values",
      "inputs": {
        "x": {
          "dtype": "float32",
          "shape": [6],
          "data": { "kind": "values", "values": [100.0, -100.0, "Infinity", "-Infinity", "NaN", 0.0] }
        }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [6], "tolerance": 0.000001, "allowNaN": true } }
    },
    {
      "name": "f32_subnormal_identity_tail_gpu_gap",
      "skipGpu": {
        "category": "permanent",
        "reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Backend evidence: WebGPU/Metal flushes subnormals to zero (f32 and f16); the kernel cannot preserve denormal inputs/outputs bit-exactly."
      },
      "provenance": {
        "source": "onnxruntime/test/providers/cpu/activation/activation_op_test.cc",
        "test": "ActivationOpTest.Tanh",
        "notes": "For tiny finite inputs tanh(x) rounds back to x in float32; zero-flushing erases the signed tail."
      },
      "inputs": {
        "x": {
          "dtype": "float32",
          "shape": [4],
          "data": { "kind": "values", "values": [1e-40, -1e-40, 1e-39, -1e-39] }
        }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [4], "tolerance": 1e-43 } }
    },
    {
      "name": "f32_subnormal_identity_tail_scalar_gpu_gap",
      "skipGpu": {
        "category": "permanent",
        "reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Backend evidence: WebGPU/Metal flushes subnormals to zero (f32 and f16); the kernel cannot preserve denormal inputs/outputs bit-exactly."
      },
      "provenance": {
        "source": "onnxruntime/test/providers/cpu/activation/activation_op_test.cc",
        "test": "ActivationOpTest.Tanh",
        "notes": "On the scalar path, tiny finite inputs should round back to their signed subnormal values."
      },
      "inputs": {
        "x": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [-1e-40, 0.0, 1e-40] } }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [3], "tolerance": 1e-43 } }
    },
    {
      "name": "ort_activation_extremes",
      "provenance": {
        "source": "onnxruntime/test/providers/cpu/activation/activation_op_test.cc",
        "test": "ActivationOpTest.Tanh",
        "notes": "ORT shared activation vector with infinities, float max, min, and subnormal values."
      },
      "inputs": {
        "x": {
          "dtype": "float32",
          "shape": [13],
          "data": {
            "kind": "values",
            "values": [-1.0, 0.0, 1.0, 100.0, -100.0, 1000.0, -1000.0, 1.1754943508222875e-38, 1.1754943508222876e-39, -1.1754943508222876e-39, 3.4028234663852886e+38, -3.4028234663852886e+38, "Infinity"]
          }
        }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [13], "tolerance": 0.000001 } }
    },
    {
      "name": "ort_fp16_activation_extremes",
      "provenance": {
        "source": "onnxruntime/test/providers/cpu/activation/activation_op_test.cc",
        "test": "ActivationOpTest.Tanh_fp16"
      },
      "inputs": {
        "x": {
          "dtype": "float16",
          "shape": [13],
          "data": {
            "kind": "values",
            "values": [-1.0, 0.0, 1.0, 100.0, -100.0, 1000.0, -1000.0, 1.1754943508222875e-38, 1.1754943508222876e-39, -1.1754943508222876e-39, 3.4028234663852886e+38, -3.4028234663852886e+38, "Infinity"]
          }
        }
      },
      "outputs": { "y": { "dtype": "float16", "shape": [13], "tolerance": 0.001 } }
    },
    {
      "name": "f16_subnormal_identity_tail_gpu_gap",
      "skipGpu": {
        "category": "permanent",
        "reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Backend evidence: WebGPU/Metal flushes subnormals to zero (f32 and f16); the kernel cannot preserve denormal inputs/outputs bit-exactly."
      },
      "provenance": {
        "source": "onnxruntime/test/providers/cpu/activation/activation_op_test.cc",
        "test": "ActivationOpTest.Tanh_fp16",
        "notes": "Exact half-subnormal inputs are valid f16 values; tanh(x) should round back to the same signed tail."
      },
      "inputs": {
        "x": {
          "dtype": "float16",
          "shape": [4],
          "data": {
            "kind": "values",
            "values": [5.960464477539063e-8, -5.960464477539063e-8, 1.1920928955078125e-7, -1.1920928955078125e-7]
          }
        }
      },
      "outputs": { "y": { "dtype": "float16", "shape": [4], "tolerance": 0 } }
    },
    {
      "name": "f16_subnormal_identity_tail_scalar_gpu_gap",
      "skipGpu": {
        "category": "permanent",
        "reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Backend evidence: WebGPU/Metal flushes subnormals to zero (f32 and f16); the kernel cannot preserve denormal inputs/outputs bit-exactly."
      },
      "provenance": {
        "source": "onnxruntime/test/providers/cpu/activation/activation_op_test.cc",
        "test": "ActivationOpTest.Tanh_fp16",
        "notes": "The scalar path exercises exact float16 subnormal Tanh identity behavior."
      },
      "inputs": {
        "x": {
          "dtype": "float16",
          "shape": [3],
          "data": { "kind": "values", "values": [-5.960464477539063e-8, 0.0, 5.960464477539063e-8] }
        }
      },
      "outputs": { "y": { "dtype": "float16", "shape": [3], "tolerance": 0 } }
    },
    {
      "name": "onnx_backend_example",
      "provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_tanh_example" },
      "inputs": { "x": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [-1.0, 0.0, 1.0] } } },
      "outputs": { "y": { "dtype": "float32", "shape": [3], "tolerance": 0.000001 } }
    },
    {
      "name": "onnx_backend_tanh",
      "provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_tanh" },
      "inputs": {
        "x": {
          "dtype": "float32",
          "shape": [3, 4, 5],
          "data": {
            "kind": "values",
            "values": [1.764052391052246, 0.40015721321105957, 0.978738009929657, 2.2408931255340576, 1.8675580024719238, -0.9772778749465942, 0.9500884413719177, -0.15135720372200012, -0.10321885347366333, 0.4105985164642334, 0.14404356479644775, 1.4542734622955322, 0.7610377073287964, 0.12167501449584961, 0.44386324286460876, 0.3336743414402008, 1.4940791130065918, -0.2051582634449005, 0.3130677044391632, -0.8540957570075989, -2.5529897212982178, 0.653618574142456, 0.8644362092018127, -0.7421650290489197, 2.269754648208618, -1.4543657302856445, 0.04575851559638977, -0.18718385696411133, 1.5327792167663574, 1.4693588018417358, 0.154947429895401, 0.37816253304481506, -0.8877857327461243, -1.980796456336975, -0.34791216254234314, 0.15634897351264954, 1.2302906513214111, 1.202379822731018, -0.38732680678367615, -0.302302747964859, -1.0485529899597168, -1.420017957687378, -1.7062702178955078, 1.950775384902954, -0.5096521973609924, -0.4380742907524109, -1.2527953386306763, 0.7774903774261475, -1.6138978004455566, -0.21274028718471527, -0.8954665660858154, 0.38690251111984253, -0.5108051300048828, -1.18063223361969, -0.02818222902715206, 0.4283318817615509, 0.06651721894741058, 0.30247190594673157, -0.6343221068382263, -0.3627411723136902]
          }
        }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [3, 4, 5], "tolerance": 0.00001 } }
    },
    {
      "name": "onnx_backend_tanh_example",
      "provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_tanh_example" },
      "inputs": { "x": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [-1.0, 0.0, 1.0] } } },
      "outputs": { "y": { "dtype": "float32", "shape": [3], "tolerance": 0.00001 } }
    },
    {
      "name": "vec4_f16_lanes",
      "inputs": {
        "x": {
          "dtype": "float16",
          "shape": [16],
          "data": {
            "kind": "values",
            "values": [-6.0, -4.0, -3.0, -2.0, -1.5, -1.0, -0.5, -0.25, 0.0, 0.25, 0.5, 1.0, 1.5, 2.0, 4.0, 6.0]
          }
        }
      },
      "outputs": { "y": { "dtype": "float16", "shape": [16], "tolerance": 0.001, "relTolerance": 0.002 } }
    },
    {
      "name": "vec4_f32_extremes",
      "inputs": {
        "x": {
          "dtype": "float32",
          "shape": [8],
          "data": { "kind": "values", "values": [100.0, -100.0, "Infinity", "-Infinity", "NaN", 0.0, 9.9, -9.9] }
        }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [8], "tolerance": 0.000001, "allowNaN": true } }
    },
    {
      "name": "empty_input_zero_dim",
      "inputs": { "x": { "dtype": "float32", "shape": [0], "data": { "kind": "values", "values": [] } } },
      "outputs": { "y": { "dtype": "float32", "shape": [0], "tolerance": 0 } }
    },
    {
      "name": "f16_scalar_fallback_saturation_and_tiny",
      "provenance": {
        "source": "synthetic",
        "notes": "Seven float16 elements exercise scalar processing. Exact float16 inputs cover saturation at magnitude 10 and the tiny-normal identity branch at 2^-13 without relying on subnormal preservation."
      },
      "inputs": {
        "x": {
          "dtype": "float16",
          "shape": [7],
          "data": { "kind": "values", "values": [10.0, -10.0, 0.0, 0.5, -0.5, 0.0001220703125, -0.0001220703125] }
        }
      },
      "outputs": { "y": { "dtype": "float16", "shape": [7], "tolerance": 0.003 } }
    },
    {
      "name": "f16_scalar_fallback_midrange",
      "provenance": {
        "source": "synthetic",
        "notes": "Second odd-numel (5%4!=0) f16 scalar-fallback case over the steep mid-range of tanh where output precision matters most; complements the saturation/tiny case. f16-exact inputs (quarter-fractions)."
      },
      "inputs": {
        "x": { "dtype": "float16", "shape": [5], "data": { "kind": "values", "values": [-2.0, -0.75, 0.25, 1.0, 1.5] } }
      },
      "outputs": { "y": { "dtype": "float16", "shape": [5], "tolerance": 0.003 } }
    },
    {
      "name": "vec4_path_tiny_x_identity_branch",
      "inputs": {
        "x": {
          "dtype": "float32",
          "shape": [8],
          "data": {
            "kind": "values",
            "values": [0.00001, -0.00001, 0.00005, -0.00005, 0.000099, -0.000099, 0.0001, 0.0]
          }
        }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [8], "tolerance": 1e-7 } }
    },
    {
      "name": "f32_vec4_sustained_4096",
      "provenance": { "notes": "A compact aligned float32 payload exercises vectorized Tanh across multiple lanes." },
      "inputs": {
        "x": {
          "dtype": "float32",
          "shape": [4096],
          "data": { "kind": "fillFloat32", "sinStep": 0.019, "cosStep": 0.007, "scale": 0.5 }
        }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [4096], "tolerance": 0.000001 } }
    },
    {
      "name": "f32_scalar_tail_4095",
      "provenance": { "notes": "An odd float32 element count exercises scalar Tanh." },
      "inputs": {
        "x": {
          "dtype": "float32",
          "shape": [4095],
          "data": { "kind": "fillFloat32", "sinStep": 0.017, "cosStep": 0.011, "scale": 0.5 }
        }
      },
      "outputs": { "y": { "dtype": "float32", "shape": [4095], "tolerance": 0.000001 } }
    }
  ]
}