File: ops.mlir

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (300 lines) | stat: -rw-r--r-- 12,180 bytes parent folder | download | duplicates (10)
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
// RUN: mlir-opt %s | mlir-opt | FileCheck %s
// RUN: mlir-opt %s --mlir-print-op-generic | mlir-opt | FileCheck %s

// CHECK-LABEL: func @atan(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @atan(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.atan %[[F]] : f32
  %0 = math.atan %f : f32
  // CHECK: %{{.*}} = math.atan %[[V]] : vector<4xf32>
  %1 = math.atan %v : vector<4xf32>
  // CHECK: %{{.*}} = math.atan %[[T]] : tensor<4x4x?xf32>
  %2 = math.atan %t : tensor<4x4x?xf32>
  return
}


// CHECK-LABEL: func @atan2(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @atan2(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.atan2 %[[F]], %[[F]] : f32
  %0 = math.atan2 %f, %f : f32
  // CHECK: %{{.*}} = math.atan2 %[[V]], %[[V]] : vector<4xf32>
  %1 = math.atan2 %v, %v : vector<4xf32>
  // CHECK: %{{.*}} = math.atan2 %[[T]], %[[T]] : tensor<4x4x?xf32>
  %2 = math.atan2 %t, %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @cbrt(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @cbrt(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.cbrt %[[F]] : f32
  %0 = math.cbrt %f : f32
  // CHECK: %{{.*}} = math.cbrt %[[V]] : vector<4xf32>
  %1 = math.cbrt %v : vector<4xf32>
  // CHECK: %{{.*}} = math.cbrt %[[T]] : tensor<4x4x?xf32>
  %2 = math.cbrt %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @cos(
// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @cos(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.cos %[[F]] : f32
  %0 = math.cos %f : f32
  // CHECK: %{{.*}} = math.cos %[[V]] : vector<4xf32>
  %1 = math.cos %v : vector<4xf32>
  // CHECK: %{{.*}} = math.cos %[[T]] : tensor<4x4x?xf32>
  %2 = math.cos %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @sin(
// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @sin(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.sin %[[F]] : f32
  %0 = math.sin %f : f32
  // CHECK: %{{.*}} = math.sin %[[V]] : vector<4xf32>
  %1 = math.sin %v : vector<4xf32>
  // CHECK: %{{.*}} = math.sin %[[T]] : tensor<4x4x?xf32>
  %2 = math.sin %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @erf(
// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @erf(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.erf %[[F]] : f32
  %0 = math.erf %f : f32
  // CHECK: %{{.*}} = math.erf %[[V]] : vector<4xf32>
  %1 = math.erf %v : vector<4xf32>
  // CHECK: %{{.*}} = math.erf %[[T]] : tensor<4x4x?xf32>
  %2 = math.erf %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @exp(
// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @exp(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.exp %[[F]] : f32
  %0 = math.exp %f : f32
  // CHECK: %{{.*}} = math.exp %[[V]] : vector<4xf32>
  %1 = math.exp %v : vector<4xf32>
  // CHECK: %{{.*}} = math.exp %[[T]] : tensor<4x4x?xf32>
  %2 = math.exp %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @exp2(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @exp2(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.exp2 %[[F]] : f32
  %0 = math.exp2 %f : f32
  // CHECK: %{{.*}} = math.exp2 %[[V]] : vector<4xf32>
  %1 = math.exp2 %v : vector<4xf32>
  // CHECK: %{{.*}} = math.exp2 %[[T]] : tensor<4x4x?xf32>
  %2 = math.exp2 %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @expm1(
// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @expm1(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.expm1 %[[F]] : f32
  %0 = math.expm1 %f : f32
  // CHECK: %{{.*}} = math.expm1 %[[V]] : vector<4xf32>
  %1 = math.expm1 %v : vector<4xf32>
  // CHECK: %{{.*}} = math.expm1 %[[T]] : tensor<4x4x?xf32>
  %2 = math.expm1 %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @log(
// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @log(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.log %[[F]] : f32
  %0 = math.log %f : f32
  // CHECK: %{{.*}} = math.log %[[V]] : vector<4xf32>
  %1 = math.log %v : vector<4xf32>
  // CHECK: %{{.*}} = math.log %[[T]] : tensor<4x4x?xf32>
  %2 = math.log %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @log10(
// CHECK-SAME:              %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @log10(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.log10 %[[F]] : f32
  %0 = math.log10 %f : f32
  // CHECK: %{{.*}} = math.log10 %[[V]] : vector<4xf32>
  %1 = math.log10 %v : vector<4xf32>
  // CHECK: %{{.*}} = math.log10 %[[T]] : tensor<4x4x?xf32>
  %2 = math.log10 %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @log1p(
// CHECK-SAME:              %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @log1p(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.log1p %[[F]] : f32
  %0 = math.log1p %f : f32
  // CHECK: %{{.*}} = math.log1p %[[V]] : vector<4xf32>
  %1 = math.log1p %v : vector<4xf32>
  // CHECK: %{{.*}} = math.log1p %[[T]] : tensor<4x4x?xf32>
  %2 = math.log1p %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @log2(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @log2(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.log2 %[[F]] : f32
  %0 = math.log2 %f : f32
  // CHECK: %{{.*}} = math.log2 %[[V]] : vector<4xf32>
  %1 = math.log2 %v : vector<4xf32>
  // CHECK: %{{.*}} = math.log2 %[[T]] : tensor<4x4x?xf32>
  %2 = math.log2 %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @powf(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @powf(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.powf %[[F]], %[[F]] : f32
  %0 = math.powf %f, %f : f32
  // CHECK: %{{.*}} = math.powf %[[V]], %[[V]] : vector<4xf32>
  %1 = math.powf %v, %v : vector<4xf32>
  // CHECK: %{{.*}} = math.powf %[[T]], %[[T]] : tensor<4x4x?xf32>
  %2 = math.powf %t, %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @fpowi(
// CHECK-SAME: %[[SB:.*]]: f32, %[[SP:.*]]: i32,
// CHECK-SAME: %[[VB:.*]]: vector<4xf64>, %[[VP:.*]]: vector<4xi16>,
// CHECK-SAME: %[[TB:.*]]: tensor<4x3x?xf16>, %[[TP:.*]]: tensor<4x3x?xi64>) {
func.func @fpowi(%b: f32, %p: i32, %vb: vector<4xf64>, %vp: vector<4xi16>, %tb: tensor<4x3x?xf16>, %tp: tensor<4x3x?xi64>) {
// CHECK: {{.*}} = math.fpowi %[[SB]], %[[SP]] : f32, i32
  %0 = math.fpowi %b, %p : f32, i32
// CHECK: {{.*}} = math.fpowi %[[VB]], %[[VP]] : vector<4xf64>, vector<4xi16>
  %1 = math.fpowi %vb, %vp : vector<4xf64>, vector<4xi16>
// CHECK: {{.*}} = math.fpowi %[[TB]], %[[TP]] : tensor<4x3x?xf16>, tensor<4x3x?xi64>
  %2 = math.fpowi %tb, %tp : tensor<4x3x?xf16>, tensor<4x3x?xi64>
  return
}

// CHECK-LABEL: func @rsqrt(
// CHECK-SAME:              %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @rsqrt(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.rsqrt %[[F]] : f32
  %0 = math.rsqrt %f : f32
  // CHECK: %{{.*}} = math.rsqrt %[[V]] : vector<4xf32>
  %1 = math.rsqrt %v : vector<4xf32>
  // CHECK: %{{.*}} = math.rsqrt %[[T]] : tensor<4x4x?xf32>
  %2 = math.rsqrt %t : tensor<4x4x?xf32>
  return
}


// CHECK-LABEL: func @sqrt(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @sqrt(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.sqrt %[[F]] : f32
  %0 = math.sqrt %f : f32
  // CHECK: %{{.*}} = math.sqrt %[[V]] : vector<4xf32>
  %1 = math.sqrt %v : vector<4xf32>
  // CHECK: %{{.*}} = math.sqrt %[[T]] : tensor<4x4x?xf32>
  %2 = math.sqrt %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @tan(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @tan(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.tan %[[F]] : f32
  %0 = math.tan %f : f32
  // CHECK: %{{.*}} = math.tan %[[V]] : vector<4xf32>
  %1 = math.tan %v : vector<4xf32>
  // CHECK: %{{.*}} = math.tan %[[T]] : tensor<4x4x?xf32>
  %2 = math.tan %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @tanh(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @tanh(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.tanh %[[F]] : f32
  %0 = math.tanh %f : f32
  // CHECK: %{{.*}} = math.tanh %[[V]] : vector<4xf32>
  %1 = math.tanh %v : vector<4xf32>
  // CHECK: %{{.*}} = math.tanh %[[T]] : tensor<4x4x?xf32>
  %2 = math.tanh %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @round(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @round(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.round %[[F]] : f32
  %0 = math.round %f : f32
  // CHECK: %{{.*}} = math.round %[[V]] : vector<4xf32>
  %1 = math.round %v : vector<4xf32>
  // CHECK: %{{.*}} = math.round %[[T]] : tensor<4x4x?xf32>
  %2 = math.round %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @roundeven(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @roundeven(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.roundeven %[[F]] : f32
  %0 = math.roundeven %f : f32
  // CHECK: %{{.*}} = math.roundeven %[[V]] : vector<4xf32>
  %1 = math.roundeven %v : vector<4xf32>
  // CHECK: %{{.*}} = math.roundeven %[[T]] : tensor<4x4x?xf32>
  %2 = math.roundeven %t : tensor<4x4x?xf32>
  return
}


// CHECK-LABEL: func @ipowi(
// CHECK-SAME:             %[[I:.*]]: i32, %[[V:.*]]: vector<4xi32>, %[[T:.*]]: tensor<4x4x?xi32>)
func.func @ipowi(%i: i32, %v: vector<4xi32>, %t: tensor<4x4x?xi32>) {
  // CHECK: %{{.*}} = math.ipowi %[[I]], %[[I]] : i32
  %0 = math.ipowi %i, %i : i32
  // CHECK: %{{.*}} = math.ipowi %[[V]], %[[V]] : vector<4xi32>
  %1 = math.ipowi %v, %v : vector<4xi32>
  // CHECK: %{{.*}} = math.ipowi %[[T]], %[[T]] : tensor<4x4x?xi32>
  %2 = math.ipowi %t, %t : tensor<4x4x?xi32>
  return
}

// CHECK-LABEL: func @trunc(
// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @trunc(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: %{{.*}} = math.trunc %[[F]] : f32
  %0 = math.trunc %f : f32
  // CHECK: %{{.*}} = math.trunc %[[V]] : vector<4xf32>
  %1 = math.trunc %v : vector<4xf32>
  // CHECK: %{{.*}} = math.trunc %[[T]] : tensor<4x4x?xf32>
  %2 = math.trunc %t : tensor<4x4x?xf32>
  return
}

// CHECK-LABEL: func @fastmath(
// CHECK-SAME:      %[[F:.*]]: f32, %[[I:.*]]: i32,
// CHECK-SAME:      %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
func.func @fastmath(%f: f32, %i: i32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
  // CHECK: math.trunc %[[F]] fastmath<fast> : f32
  %0 = math.trunc %f fastmath<fast> : f32
  // CHECK: math.powf %[[V]], %[[V]] fastmath<fast> : vector<4xf32>
  %1 = math.powf %v, %v fastmath<reassoc,nnan,ninf,nsz,arcp,contract,afn> : vector<4xf32>
  // CHECK: math.fma %[[T]], %[[T]], %[[T]] : tensor<4x4x?xf32>
  %2 = math.fma %t, %t, %t fastmath<none> : tensor<4x4x?xf32>
  // CHECK: math.absf %[[F]] fastmath<ninf> : f32
  %3 = math.absf %f fastmath<ninf> : f32
  // CHECK: math.fpowi %[[F]], %[[I]] fastmath<fast> : f32, i32
  %4 = math.fpowi %f, %i fastmath<fast> : f32, i32
  return
}