16
16
namespace sycl {
17
17
inline namespace _V1 {
18
18
namespace ext ::intel::math {
19
- sycl::half hadd (sycl::half x, sycl::half y) { return x + y; }
19
+ inline sycl::half hadd (sycl::half x, sycl::half y) { return x + y; }
20
20
21
- sycl::half hadd_sat (sycl::half x, sycl::half y) {
21
+ inline sycl::half hadd_sat (sycl::half x, sycl::half y) {
22
22
return sycl::clamp ((x + y), sycl::half (0 .f ), sycl::half (1 .0f ));
23
23
}
24
24
25
- sycl::half hfma (sycl::half x, sycl::half y, sycl::half z) {
25
+ inline sycl::half hfma (sycl::half x, sycl::half y, sycl::half z) {
26
26
return sycl::fma (x, y, z);
27
27
}
28
28
29
- sycl::half hfma_sat (sycl::half x, sycl::half y, sycl::half z) {
29
+ inline sycl::half hfma_sat (sycl::half x, sycl::half y, sycl::half z) {
30
30
return sycl::clamp (sycl::fma (x, y, z), sycl::half (0 .f ), sycl::half (1 .0f ));
31
31
}
32
32
33
- sycl::half hmul (sycl::half x, sycl::half y) { return x * y; }
33
+ inline sycl::half hmul (sycl::half x, sycl::half y) { return x * y; }
34
34
35
- sycl::half hmul_sat (sycl::half x, sycl::half y) {
35
+ inline sycl::half hmul_sat (sycl::half x, sycl::half y) {
36
36
return sycl::clamp ((x * y), sycl::half (0 .f ), sycl::half (1 .0f ));
37
37
}
38
38
39
- sycl::half hneg (sycl::half x) { return -x; }
39
+ inline sycl::half hneg (sycl::half x) { return -x; }
40
40
41
- sycl::half hsub (sycl::half x, sycl::half y) { return x - y; }
41
+ inline sycl::half hsub (sycl::half x, sycl::half y) { return x - y; }
42
42
43
- sycl::half hsub_sat (sycl::half x, sycl::half y) {
43
+ inline sycl::half hsub_sat (sycl::half x, sycl::half y) {
44
44
return sycl::clamp ((x - y), sycl::half (0 .f ), sycl::half (1 .0f ));
45
45
}
46
46
47
- sycl::half hdiv (sycl::half x, sycl::half y) { return x / y; }
47
+ inline sycl::half hdiv (sycl::half x, sycl::half y) { return x / y; }
48
48
49
- bool heq (sycl::half x, sycl::half y) { return x == y; }
49
+ inline bool heq (sycl::half x, sycl::half y) { return x == y; }
50
50
51
- bool hequ (sycl::half x, sycl::half y) {
51
+ inline bool hequ (sycl::half x, sycl::half y) {
52
52
if (sycl::isnan (x) || sycl::isnan (y))
53
53
return true ;
54
54
else
55
55
return x == y;
56
56
}
57
57
58
- bool hge (sycl::half x, sycl::half y) { return x >= y; }
58
+ inline bool hge (sycl::half x, sycl::half y) { return x >= y; }
59
59
60
- bool hgeu (sycl::half x, sycl::half y) {
60
+ inline bool hgeu (sycl::half x, sycl::half y) {
61
61
if (sycl::isnan (x) || sycl::isnan (y))
62
62
return true ;
63
63
else
64
64
return x >= y;
65
65
}
66
66
67
- bool hgt (sycl::half x, sycl::half y) { return x > y; }
67
+ inline bool hgt (sycl::half x, sycl::half y) { return x > y; }
68
68
69
- bool hgtu (sycl::half x, sycl::half y) {
69
+ inline bool hgtu (sycl::half x, sycl::half y) {
70
70
if (sycl::isnan (x) || sycl::isnan (y))
71
71
return true ;
72
72
else
73
73
return x > y;
74
74
}
75
75
76
- bool hle (sycl::half x, sycl::half y) { return x <= y; }
76
+ inline bool hle (sycl::half x, sycl::half y) { return x <= y; }
77
77
78
- bool hleu (sycl::half x, sycl::half y) {
78
+ inline bool hleu (sycl::half x, sycl::half y) {
79
79
if (sycl::isnan (x) || sycl::isnan (y))
80
80
return true ;
81
81
else
82
82
return x <= y;
83
83
}
84
84
85
- bool hlt (sycl::half x, sycl::half y) { return x < y; }
85
+ inline bool hlt (sycl::half x, sycl::half y) { return x < y; }
86
86
87
- bool hltu (sycl::half x, sycl::half y) {
87
+ inline bool hltu (sycl::half x, sycl::half y) {
88
88
if (sycl::isnan (x) || sycl::isnan (y))
89
89
return true ;
90
90
return x < y;
91
91
}
92
92
93
- bool hne (sycl::half x, sycl::half y) {
93
+ inline bool hne (sycl::half x, sycl::half y) {
94
94
if (sycl::isnan (x) || sycl::isnan (y))
95
95
return false ;
96
96
return x != y;
97
97
}
98
98
99
- bool hneu (sycl::half x, sycl::half y) {
99
+ inline bool hneu (sycl::half x, sycl::half y) {
100
100
if (sycl::isnan (x) || sycl::isnan (y))
101
101
return true ;
102
102
else
103
103
return x != y;
104
104
}
105
105
106
- bool hisinf (sycl::half x) { return sycl::isinf (x); }
107
- bool hisnan (sycl::half y) { return sycl::isnan (y); }
106
+ inline bool hisinf (sycl::half x) { return sycl::isinf (x); }
107
+ inline bool hisnan (sycl::half y) { return sycl::isnan (y); }
108
108
109
- sycl::half2 hadd2 (sycl::half2 x, sycl::half2 y) { return x + y; }
109
+ inline sycl::half2 hadd2 (sycl::half2 x, sycl::half2 y) { return x + y; }
110
110
111
- sycl::half2 hadd2_sat (sycl::half2 x, sycl::half2 y) {
111
+ inline sycl::half2 hadd2_sat (sycl::half2 x, sycl::half2 y) {
112
112
return sycl::clamp ((x + y), sycl::half2{0 .f , 0 .f }, sycl::half2{1 .f , 1 .f });
113
113
}
114
114
115
- sycl::half2 hfma2 (sycl::half2 x, sycl::half2 y, sycl::half2 z) {
115
+ inline sycl::half2 hfma2 (sycl::half2 x, sycl::half2 y, sycl::half2 z) {
116
116
return sycl::fma (x, y, z);
117
117
}
118
118
119
- sycl::half2 hfma2_sat (sycl::half2 x, sycl::half2 y, sycl::half2 z) {
119
+ inline sycl::half2 hfma2_sat (sycl::half2 x, sycl::half2 y, sycl::half2 z) {
120
120
return sycl::clamp (sycl::fma (x, y, z), sycl::half2{0 .f , 0 .f },
121
121
sycl::half2{1 .f , 1 .f });
122
122
}
123
123
124
- sycl::half2 hmul2 (sycl::half2 x, sycl::half2 y) { return x * y; }
124
+ inline sycl::half2 hmul2 (sycl::half2 x, sycl::half2 y) { return x * y; }
125
125
126
- sycl::half2 hmul2_sat (sycl::half2 x, sycl::half2 y) {
126
+ inline sycl::half2 hmul2_sat (sycl::half2 x, sycl::half2 y) {
127
127
return sycl::clamp ((x * y), sycl::half2{0 .f , 0 .f }, sycl::half2{1 .f , 1 .f });
128
128
}
129
129
130
- sycl::half2 h2div (sycl::half2 x, sycl::half2 y) { return x / y; }
130
+ inline sycl::half2 h2div (sycl::half2 x, sycl::half2 y) { return x / y; }
131
131
132
- sycl::half2 hneg2 (sycl::half2 x) { return -x; }
132
+ inline sycl::half2 hneg2 (sycl::half2 x) { return -x; }
133
133
134
- sycl::half2 hsub2 (sycl::half2 x, sycl::half2 y) { return x - y; }
134
+ inline sycl::half2 hsub2 (sycl::half2 x, sycl::half2 y) { return x - y; }
135
135
136
- sycl::half2 hsub2_sat (sycl::half2 x, sycl::half2 y) {
136
+ inline sycl::half2 hsub2_sat (sycl::half2 x, sycl::half2 y) {
137
137
return sycl::clamp ((x - y), sycl::half2{0 .f , 0 .f }, sycl::half2{1 .f , 1 .f });
138
138
}
139
139
140
- bool hbeq2 (sycl::half2 x, sycl::half2 y) {
140
+ inline bool hbeq2 (sycl::half2 x, sycl::half2 y) {
141
141
return heq (x.s0 (), y.s0 ()) && heq (x.s1 (), y.s1 ());
142
142
}
143
143
144
- bool hbequ2 (sycl::half2 x, sycl::half2 y) {
144
+ inline bool hbequ2 (sycl::half2 x, sycl::half2 y) {
145
145
return hequ (x.s0 (), y.s0 ()) && hequ (x.s1 (), y.s1 ());
146
146
}
147
147
148
- bool hbge2 (sycl::half2 x, sycl::half2 y) {
148
+ inline bool hbge2 (sycl::half2 x, sycl::half2 y) {
149
149
return hge (x.s0 (), y.s0 ()) && hge (x.s1 (), y.s1 ());
150
150
}
151
151
152
- bool hbgeu2 (sycl::half2 x, sycl::half2 y) {
152
+ inline bool hbgeu2 (sycl::half2 x, sycl::half2 y) {
153
153
return hgeu (x.s0 (), y.s0 ()) && hgeu (x.s1 (), y.s1 ());
154
154
}
155
155
156
- bool hbgt2 (sycl::half2 x, sycl::half2 y) {
156
+ inline bool hbgt2 (sycl::half2 x, sycl::half2 y) {
157
157
return hgt (x.s0 (), y.s0 ()) && hgt (x.s1 (), y.s1 ());
158
158
}
159
159
160
- bool hbgtu2 (sycl::half2 x, sycl::half2 y) {
160
+ inline bool hbgtu2 (sycl::half2 x, sycl::half2 y) {
161
161
return hgtu (x.s0 (), y.s0 ()) && hgtu (x.s1 (), y.s1 ());
162
162
}
163
163
164
- bool hble2 (sycl::half2 x, sycl::half2 y) {
164
+ inline bool hble2 (sycl::half2 x, sycl::half2 y) {
165
165
return hle (x.s0 (), y.s0 ()) && hle (x.s1 (), y.s1 ());
166
166
}
167
167
168
- bool hbleu2 (sycl::half2 x, sycl::half2 y) {
168
+ inline bool hbleu2 (sycl::half2 x, sycl::half2 y) {
169
169
return hleu (x.s0 (), y.s0 ()) && hleu (x.s1 (), y.s1 ());
170
170
}
171
171
172
- bool hblt2 (sycl::half2 x, sycl::half2 y) {
172
+ inline bool hblt2 (sycl::half2 x, sycl::half2 y) {
173
173
return hlt (x.s0 (), y.s0 ()) && hlt (x.s1 (), y.s1 ());
174
174
}
175
175
176
- bool hbltu2 (sycl::half2 x, sycl::half2 y) {
176
+ inline bool hbltu2 (sycl::half2 x, sycl::half2 y) {
177
177
return hltu (x.s0 (), y.s0 ()) && hltu (x.s1 (), y.s1 ());
178
178
}
179
179
180
- bool hbne2 (sycl::half2 x, sycl::half2 y) {
180
+ inline bool hbne2 (sycl::half2 x, sycl::half2 y) {
181
181
return hne (x.s0 (), y.s0 ()) && hne (x.s1 (), y.s1 ());
182
182
}
183
183
184
- bool hbneu2 (sycl::half2 x, sycl::half2 y) {
184
+ inline bool hbneu2 (sycl::half2 x, sycl::half2 y) {
185
185
return hneu (x.s0 (), y.s0 ()) && hneu (x.s1 (), y.s1 ());
186
186
}
187
187
188
- sycl::half2 heq2 (sycl::half2 x, sycl::half2 y) {
188
+ inline sycl::half2 heq2 (sycl::half2 x, sycl::half2 y) {
189
189
return sycl::half2{(heq (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
190
190
(heq (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
191
191
}
192
192
193
- sycl::half2 hequ2 (sycl::half2 x, sycl::half2 y) {
193
+ inline sycl::half2 hequ2 (sycl::half2 x, sycl::half2 y) {
194
194
return sycl::half2{(hequ (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
195
195
(hequ (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
196
196
}
197
197
198
- sycl::half2 hge2 (sycl::half2 x, sycl::half2 y) {
198
+ inline sycl::half2 hge2 (sycl::half2 x, sycl::half2 y) {
199
199
return sycl::half2{(hge (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
200
200
(hge (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
201
201
}
202
202
203
- sycl::half2 hgeu2 (sycl::half2 x, sycl::half2 y) {
203
+ inline sycl::half2 hgeu2 (sycl::half2 x, sycl::half2 y) {
204
204
return sycl::half2{(hgeu (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
205
205
(hgeu (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
206
206
}
207
207
208
- sycl::half2 hgt2 (sycl::half2 x, sycl::half2 y) {
208
+ inline sycl::half2 hgt2 (sycl::half2 x, sycl::half2 y) {
209
209
return sycl::half2{(hgt (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
210
210
(hgt (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
211
211
}
212
212
213
- sycl::half2 hgtu2 (sycl::half2 x, sycl::half2 y) {
213
+ inline sycl::half2 hgtu2 (sycl::half2 x, sycl::half2 y) {
214
214
return sycl::half2{(hgtu (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
215
215
(hgtu (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
216
216
}
217
217
218
- sycl::half2 hle2 (sycl::half2 x, sycl::half2 y) {
218
+ inline sycl::half2 hle2 (sycl::half2 x, sycl::half2 y) {
219
219
return sycl::half2{(hle (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
220
220
(hle (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
221
221
}
222
222
223
- sycl::half2 hleu2 (sycl::half2 x, sycl::half2 y) {
223
+ inline sycl::half2 hleu2 (sycl::half2 x, sycl::half2 y) {
224
224
return sycl::half2{(hleu (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
225
225
(hleu (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
226
226
}
227
227
228
- sycl::half2 hlt2 (sycl::half2 x, sycl::half2 y) {
228
+ inline sycl::half2 hlt2 (sycl::half2 x, sycl::half2 y) {
229
229
return sycl::half2{(hlt (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
230
230
(hlt (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
231
231
}
232
232
233
- sycl::half2 hltu2 (sycl::half2 x, sycl::half2 y) {
233
+ inline sycl::half2 hltu2 (sycl::half2 x, sycl::half2 y) {
234
234
return sycl::half2{(hltu (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
235
235
(hltu (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
236
236
}
237
237
238
- sycl::half2 hisnan2 (sycl::half2 x) {
238
+ inline sycl::half2 hisnan2 (sycl::half2 x) {
239
239
return sycl::half2{(hisnan (x.s0 ()) ? 1 .0f : 0 .f ),
240
240
(hisnan (x.s1 ()) ? 1 .0f : 0 .f )};
241
241
}
242
242
243
- sycl::half2 hne2 (sycl::half2 x, sycl::half2 y) {
243
+ inline sycl::half2 hne2 (sycl::half2 x, sycl::half2 y) {
244
244
return sycl::half2{(hne (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
245
245
(hne (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
246
246
}
247
247
248
- sycl::half2 hneu2 (sycl::half2 x, sycl::half2 y) {
248
+ inline sycl::half2 hneu2 (sycl::half2 x, sycl::half2 y) {
249
249
return sycl::half2{(hneu (x.s0 (), y.s0 ()) ? 1 .0f : 0 .f ),
250
250
(hneu (x.s1 (), y.s1 ()) ? 1 .0f : 0 .f )};
251
251
}
252
252
253
- sycl::half hmax (sycl::half x, sycl::half y) { return sycl::fmax (x, y); }
253
+ inline sycl::half hmax (sycl::half x, sycl::half y) { return sycl::fmax (x, y); }
254
254
255
- sycl::half hmax_nan (sycl::half x, sycl::half y) {
255
+ inline sycl::half hmax_nan (sycl::half x, sycl::half y) {
256
256
if (hisnan (x) || hisnan (y))
257
257
return sycl::half (std::numeric_limits<float >::quiet_NaN ());
258
258
else
259
259
return sycl::fmax (x, y);
260
260
}
261
261
262
- sycl::half2 hmax2 (sycl::half2 x, sycl::half2 y) {
262
+ inline sycl::half2 hmax2 (sycl::half2 x, sycl::half2 y) {
263
263
return sycl::half2{hmax (x.s0 (), y.s0 ()), hmax (x.s1 (), y.s1 ())};
264
264
}
265
265
266
- sycl::half2 hmax2_nan (sycl::half2 x, sycl::half2 y) {
266
+ inline sycl::half2 hmax2_nan (sycl::half2 x, sycl::half2 y) {
267
267
return sycl::half2{hmax_nan (x.s0 (), y.s0 ()), hmax_nan (x.s1 (), y.s1 ())};
268
268
}
269
269
270
- sycl::half hmin (sycl::half x, sycl::half y) { return sycl::fmin (x, y); }
270
+ inline sycl::half hmin (sycl::half x, sycl::half y) { return sycl::fmin (x, y); }
271
271
272
- sycl::half hmin_nan (sycl::half x, sycl::half y) {
272
+ inline sycl::half hmin_nan (sycl::half x, sycl::half y) {
273
273
if (hisnan (x) || hisnan (y))
274
274
return sycl::half (std::numeric_limits<float >::quiet_NaN ());
275
275
else
276
276
return sycl::fmin (x, y);
277
277
}
278
278
279
- sycl::half2 hmin2 (sycl::half2 x, sycl::half2 y) {
279
+ inline sycl::half2 hmin2 (sycl::half2 x, sycl::half2 y) {
280
280
return sycl::half2{hmin (x.s0 (), y.s0 ()), hmin (x.s1 (), y.s1 ())};
281
281
}
282
282
283
- sycl::half2 hmin2_nan (sycl::half2 x, sycl::half2 y) {
283
+ inline sycl::half2 hmin2_nan (sycl::half2 x, sycl::half2 y) {
284
284
return sycl::half2{hmin_nan (x.s0 (), y.s0 ()), hmin_nan (x.s1 (), y.s1 ())};
285
285
}
286
286
287
- sycl::half2 hcmadd (sycl::half2 x, sycl::half2 y, sycl::half2 z) {
287
+ inline sycl::half2 hcmadd (sycl::half2 x, sycl::half2 y, sycl::half2 z) {
288
288
return sycl::half2{x.s0 () * y.s0 () - x.s1 () * y.s1 () + z.s0 (),
289
289
x.s0 () * y.s1 () + x.s1 () * y.s0 () + z.s1 ()};
290
290
}
291
291
292
- sycl::half hfma_relu (sycl::half x, sycl::half y, sycl::half z) {
292
+ inline sycl::half hfma_relu (sycl::half x, sycl::half y, sycl::half z) {
293
293
sycl::half r = sycl::fma (x, y, z);
294
294
if (!hisnan (r)) {
295
295
if (r < 0 .f )
@@ -300,7 +300,7 @@ sycl::half hfma_relu(sycl::half x, sycl::half y, sycl::half z) {
300
300
return r;
301
301
}
302
302
303
- sycl::half2 hfma2_relu (sycl::half2 x, sycl::half2 y, sycl::half2 z) {
303
+ inline sycl::half2 hfma2_relu (sycl::half2 x, sycl::half2 y, sycl::half2 z) {
304
304
sycl::half2 r = sycl::fma (x, y, z);
305
305
if (!hisnan (r.s0 ()) && r.s0 () < 0 .f )
306
306
r.s0 () = 0 .f ;
@@ -309,9 +309,9 @@ sycl::half2 hfma2_relu(sycl::half2 x, sycl::half2 y, sycl::half2 z) {
309
309
return r;
310
310
}
311
311
312
- sycl::half habs (sycl::half x) { return sycl::fabs (x); }
312
+ inline sycl::half habs (sycl::half x) { return sycl::fabs (x); }
313
313
314
- sycl::half2 habs2 (sycl::half2 x) { return sycl::fabs (x); }
314
+ inline sycl::half2 habs2 (sycl::half2 x) { return sycl::fabs (x); }
315
315
} // namespace ext::intel::math
316
316
} // namespace _V1
317
317
} // namespace sycl
0 commit comments