-
Notifications
You must be signed in to change notification settings - Fork 20
/
EagerExecution.swift
557 lines (511 loc) · 21.1 KB
/
EagerExecution.swift
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
// !!! THIS CODE IS AUTOMATICALLY GENERATED, DO NOT EDIT BY HAND !!!
//
// Copyright 2018-19 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import CTensorFlow
/// **WARNING:** After constructing a `TFE_Op`, any one of its `execute` methods must be called
/// *exactly once*. If not called, then a memory leak is introduced due to the underlying TensorFlow
/// eager op object not being freed. If called more than once, then a SEGFAULT may occur due to
/// trying to execute a TensorFlow eager op that has already been freed.
@usableFromInline
internal struct TFE_Op : TFTensorOperation {
@usableFromInline internal let status: CTFStatus
@usableFromInline internal let op: CTFEOp
@usableFromInline internal let outputCount: Int
@usableFromInline
internal init(_ name: String, _ outputCount: Int) {
self.status = TF_NewStatus()
self.op = TFE_NewOp(_ExecutionContext.global.eagerContext, name, status)
self.outputCount = outputCount
}
@inlinable @inline(__always)
internal func addInput(_ input: _AnyTensorHandle) {
TFE_OpAddInput(op, input._cTensorHandle, status)
checkOk(status)
}
@inlinable @inline(__always)
internal func addInput<Scalar: TensorFlowScalar>(_ input: Tensor<Scalar>) {
TFE_OpAddInput(op, input.handle._cTensorHandle, status)
checkOk(status)
}
@inlinable @inline(__always)
internal func addInput(_ input: StringTensor) {
TFE_OpAddInput(op, input.handle._cTensorHandle, status)
checkOk(status)
}
@inlinable @inline(__always)
internal func addInput(_ input: ResourceHandle) {
TFE_OpAddInput(op, input._cTensorHandle, status)
checkOk(status)
}
@inlinable @inline(__always)
internal func addInput(_ input: VariantHandle) {
TFE_OpAddInput(op, input._cTensorHandle, status)
checkOk(status)
}
@inlinable @inline(__always)
internal func addInputList<T: TensorArrayProtocol>(_ input: T) {
let count = input._tensorHandleCount
var buffer = UnsafeMutableBufferPointer<CTensorHandle>.allocate(capacity: Int(count))
defer { buffer.deallocate() }
let pointer = UnsafeMutablePointer<OpaquePointer?>(buffer.baseAddress)
input._unpackTensorHandles(into: buffer.baseAddress)
TFE_OpAddInputList(op, pointer, count, status)
// TODO: checkOk(status)
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: Bool) {
TFE_OpSetAttrBool(op, name, value ? 1 : 0)
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: Int) {
TFE_OpSetAttrInt(op, name, Int64(value))
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: Int32) {
TFE_OpSetAttrInt(op, name, Int64(value))
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: Int64) {
TFE_OpSetAttrInt(op, name, value)
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: Float) {
TFE_OpSetAttrFloat(op, name, value)
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: Double) {
TFE_OpSetAttrFloat(op, name, Float(value))
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: String) {
value.utf8CString.withUnsafeBufferPointer { buffer in
// utf8CString is null-terminated; TFE_OpSetAttrString wants
// non-null-terminated.
TFE_OpSetAttrString(op, name, buffer.baseAddress, buffer.count - 1)
}
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: TensorDataType) {
TFE_OpSetAttrType(op, name, value._cDataType)
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: TensorShape) {
let dimensions: [Int64] = value.dimensions.map(Int64.init)
dimensions.withUnsafeBufferPointer { buffer in
TFE_OpSetAttrShape(op, name, buffer.baseAddress, Int32(buffer.count), status)
}
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: TensorShape?) {
guard let shape = value else {
TFE_OpSetAttrShape(op, name, nil, -1, status)
return
}
updateAttribute(name, shape)
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [Bool]) {
value.map({ $0 ? UInt8(1) : UInt8(0) }).withUnsafeBufferPointer { buffer in
TFE_OpSetAttrBoolList(op, name, buffer.baseAddress, Int32(buffer.count))
}
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [Int]) {
updateAttribute(name, value.map(Int64.init))
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [Int32]) {
updateAttribute(name, value.map(Int64.init))
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [Int64]) {
value.withUnsafeBufferPointer { buffer in
TFE_OpSetAttrIntList(op, name, buffer.baseAddress, Int32(buffer.count))
}
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [Float]) {
value.withUnsafeBufferPointer { buffer in
TFE_OpSetAttrFloatList(op, name, buffer.baseAddress, Int32(buffer.count))
}
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [Double]) {
updateAttribute(name, value.map(Float.init))
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [String]) {
// Collect all the strings' utf8 bytes into a single array so that we can
// address all the strings with a single
// `flattenedStringBytes.withUnsafeBufferPointer`.
var flattenedStringBytes: [CChar] = []
var lengths: [Int] = []
for string in value {
// Don't include the null-terminator because TFE_OpSetAttrStringList uses
// lengths instead of null-terminators.
let stringBytes = string.utf8CString.dropLast()
flattenedStringBytes.append(contentsOf: stringBytes)
lengths.append(stringBytes.count)
}
// Calculate the addresses of all the strings within our single buffer, and
// then call TFE_OpSetAttrStringList.
flattenedStringBytes.withUnsafeBufferPointer { flattenedStringBytesBuffer in
var stringAddrs: [UnsafeRawPointer?] = []
var currentStringAddr =
flattenedStringBytesBuffer.baseAddress.map(UnsafeRawPointer.init)
for length in lengths {
stringAddrs.append(currentStringAddr)
currentStringAddr = currentStringAddr?.advanced(by: length)
}
stringAddrs.withUnsafeBufferPointer { stringAddrsBuffer in
lengths.withUnsafeBufferPointer { lengthsBuffer in
TFE_OpSetAttrStringList(op, name, stringAddrsBuffer.baseAddress,
lengthsBuffer.baseAddress, Int32(value.count))
}
}
}
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [TensorDataType]) {
value.withUnsafeBufferPointer { buffer in
buffer.withMemoryRebound(to: TF_DataType.self) { reboundBuffer in
TFE_OpSetAttrTypeList(op, name, reboundBuffer.baseAddress, Int32(reboundBuffer.count))
}
}
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [TensorShape]) {
let flattenedDims = value.flatMap { $0.dimensions.map(Int64.init) }
let ranks = value.map { Int32($0.rank) }
flattenedDims.withUnsafeBufferPointer { flattenedDimsBuffer in
var dimsPtr: UnsafePointer<Int64>? = flattenedDimsBuffer.baseAddress
var dims: [UnsafePointer<Int64>?] = []
for rank in ranks {
dims.append(dimsPtr)
if rank >= 0 {
dimsPtr = dimsPtr.map { $0.advanced(by: Int(rank)) }
}
}
dims.withUnsafeMutableBufferPointer { dimsBuffer in
ranks.withUnsafeBufferPointer { ranksBuffer in
TFE_OpSetAttrShapeList(
op, name, dimsBuffer.baseAddress, ranksBuffer.baseAddress,
Int32(ranksBuffer.count), status)
}
}
}
}
@inlinable @inline(__always)
internal func updateAttribute(_ name: String, _ value: [TensorShape?]) {
let flattenedDims = value.flatMap { (tensorShapeOpt) -> [Int64] in
if let tensorShape = tensorShapeOpt {
return tensorShape.dimensions.map(Int64.init)
}
return []
}
let ranks = value.map { shape in (shape?.rank).map(Int32.init) ?? -1 }
flattenedDims.withUnsafeBufferPointer { flattenedDimsBuffer in
var dimsPtr: UnsafePointer<Int64>? = flattenedDimsBuffer.baseAddress
var dims: [UnsafePointer<Int64>?] = []
for rank in ranks {
dims.append(dimsPtr)
if rank >= 0 {
dimsPtr = dimsPtr.map { $0.advanced(by: Int(rank)) }
}
}
dims.withUnsafeMutableBufferPointer { dimsBuffer in
ranks.withUnsafeBufferPointer { ranksBuffer in
TFE_OpSetAttrShapeList(
op, name, dimsBuffer.baseAddress, ranksBuffer.baseAddress,
Int32(ranksBuffer.count), status)
}
}
}
}
@inlinable @inline(__always)
internal func updateAttribute<In: TensorGroup, Out: TensorGroup>(_ name: String, _ value: (In) -> Out) {
_tffunc(value).utf8CString.withUnsafeBufferPointer { buffer in
// utf8CString is null-terminated; TFE_OpSetAttrFunctionName wants
// non-null-terminated.
TFE_OpSetAttrFunctionName(op, name, buffer.baseAddress, buffer.count - 1)
}
}
/// **WARNING:** After constructing a `TFE_Op`, any one of its `execute` methods must be called
/// *exactly once*. If not called, then a memory leak is introduced due to the underlying
/// TensorFlow eager op object not being freed. If called more than once, then a SEGFAULT may
/// occur due to trying to execute a TensorFlow eager op that has already been freed.
@inlinable @inline(__always)
internal func evaluateUnsafe() -> UnsafeMutablePointer<CTensorHandle> {
var count: Int32 = Int32(self.outputCount)
let buffer: UnsafeMutablePointer<CTensorHandle> =
UnsafeMutablePointer.allocate(capacity: Int(count))
_TFCOpSetDeviceFromScope(op, status)
checkOk(status)
_TFCEagerExecute(op, UnsafeMutablePointer<CTensorHandle?>(buffer), &count, status)
checkOk(status)
TFE_DeleteOp(op)
TF_DeleteStatus(status)
return buffer
}
@inlinable @inline(__always)
internal func execute() {
let _ = evaluateUnsafe()
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol>(
_ count0: Int
) -> (T0) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0))
buffer.deallocate()
return result
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int
) -> (T0, T1) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let offset1 = offset0 + Int32(count0)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0),
T1.init(_owning: buffer.advanced(by: Int(offset1)), count: count1))
buffer.deallocate()
return result
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int
) -> (T0, T1, T2) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let offset1 = offset0 + Int32(count0)
let offset2 = offset1 + Int32(count1)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0),
T1.init(_owning: buffer.advanced(by: Int(offset1)), count: count1),
T2.init(_owning: buffer.advanced(by: Int(offset2)), count: count2))
buffer.deallocate()
return result
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int
) -> (T0, T1, T2, T3) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let offset1 = offset0 + Int32(count0)
let offset2 = offset1 + Int32(count1)
let offset3 = offset2 + Int32(count2)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0),
T1.init(_owning: buffer.advanced(by: Int(offset1)), count: count1),
T2.init(_owning: buffer.advanced(by: Int(offset2)), count: count2),
T3.init(_owning: buffer.advanced(by: Int(offset3)), count: count3))
buffer.deallocate()
return result
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int
) -> (T0, T1, T2, T3, T4) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let offset1 = offset0 + Int32(count0)
let offset2 = offset1 + Int32(count1)
let offset3 = offset2 + Int32(count2)
let offset4 = offset3 + Int32(count3)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0),
T1.init(_owning: buffer.advanced(by: Int(offset1)), count: count1),
T2.init(_owning: buffer.advanced(by: Int(offset2)), count: count2),
T3.init(_owning: buffer.advanced(by: Int(offset3)), count: count3),
T4.init(_owning: buffer.advanced(by: Int(offset4)), count: count4))
buffer.deallocate()
return result
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int
) -> (T0, T1, T2, T3, T4, T5) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let offset1 = offset0 + Int32(count0)
let offset2 = offset1 + Int32(count1)
let offset3 = offset2 + Int32(count2)
let offset4 = offset3 + Int32(count3)
let offset5 = offset4 + Int32(count4)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0),
T1.init(_owning: buffer.advanced(by: Int(offset1)), count: count1),
T2.init(_owning: buffer.advanced(by: Int(offset2)), count: count2),
T3.init(_owning: buffer.advanced(by: Int(offset3)), count: count3),
T4.init(_owning: buffer.advanced(by: Int(offset4)), count: count4),
T5.init(_owning: buffer.advanced(by: Int(offset5)), count: count5))
buffer.deallocate()
return result
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol, T6 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int,
_ count6: Int
) -> (T0, T1, T2, T3, T4, T5, T6) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let offset1 = offset0 + Int32(count0)
let offset2 = offset1 + Int32(count1)
let offset3 = offset2 + Int32(count2)
let offset4 = offset3 + Int32(count3)
let offset5 = offset4 + Int32(count4)
let offset6 = offset5 + Int32(count5)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0),
T1.init(_owning: buffer.advanced(by: Int(offset1)), count: count1),
T2.init(_owning: buffer.advanced(by: Int(offset2)), count: count2),
T3.init(_owning: buffer.advanced(by: Int(offset3)), count: count3),
T4.init(_owning: buffer.advanced(by: Int(offset4)), count: count4),
T5.init(_owning: buffer.advanced(by: Int(offset5)), count: count5),
T6.init(_owning: buffer.advanced(by: Int(offset6)), count: count6))
buffer.deallocate()
return result
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol, T6 : TensorArrayProtocol, T7 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int,
_ count6: Int,
_ count7: Int
) -> (T0, T1, T2, T3, T4, T5, T6, T7) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let offset1 = offset0 + Int32(count0)
let offset2 = offset1 + Int32(count1)
let offset3 = offset2 + Int32(count2)
let offset4 = offset3 + Int32(count3)
let offset5 = offset4 + Int32(count4)
let offset6 = offset5 + Int32(count5)
let offset7 = offset6 + Int32(count6)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0),
T1.init(_owning: buffer.advanced(by: Int(offset1)), count: count1),
T2.init(_owning: buffer.advanced(by: Int(offset2)), count: count2),
T3.init(_owning: buffer.advanced(by: Int(offset3)), count: count3),
T4.init(_owning: buffer.advanced(by: Int(offset4)), count: count4),
T5.init(_owning: buffer.advanced(by: Int(offset5)), count: count5),
T6.init(_owning: buffer.advanced(by: Int(offset6)), count: count6),
T7.init(_owning: buffer.advanced(by: Int(offset7)), count: count7))
buffer.deallocate()
return result
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol, T6 : TensorArrayProtocol, T7 : TensorArrayProtocol, T8 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int,
_ count6: Int,
_ count7: Int,
_ count8: Int
) -> (T0, T1, T2, T3, T4, T5, T6, T7, T8) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let offset1 = offset0 + Int32(count0)
let offset2 = offset1 + Int32(count1)
let offset3 = offset2 + Int32(count2)
let offset4 = offset3 + Int32(count3)
let offset5 = offset4 + Int32(count4)
let offset6 = offset5 + Int32(count5)
let offset7 = offset6 + Int32(count6)
let offset8 = offset7 + Int32(count7)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0),
T1.init(_owning: buffer.advanced(by: Int(offset1)), count: count1),
T2.init(_owning: buffer.advanced(by: Int(offset2)), count: count2),
T3.init(_owning: buffer.advanced(by: Int(offset3)), count: count3),
T4.init(_owning: buffer.advanced(by: Int(offset4)), count: count4),
T5.init(_owning: buffer.advanced(by: Int(offset5)), count: count5),
T6.init(_owning: buffer.advanced(by: Int(offset6)), count: count6),
T7.init(_owning: buffer.advanced(by: Int(offset7)), count: count7),
T8.init(_owning: buffer.advanced(by: Int(offset8)), count: count8))
buffer.deallocate()
return result
}
@inlinable @inline(__always)
internal func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol, T6 : TensorArrayProtocol, T7 : TensorArrayProtocol, T8 : TensorArrayProtocol, T9 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int,
_ count6: Int,
_ count7: Int,
_ count8: Int,
_ count9: Int
) -> (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) {
let buffer = evaluateUnsafe()
let offset0 = Int32(0)
let offset1 = offset0 + Int32(count0)
let offset2 = offset1 + Int32(count1)
let offset3 = offset2 + Int32(count2)
let offset4 = offset3 + Int32(count3)
let offset5 = offset4 + Int32(count4)
let offset6 = offset5 + Int32(count5)
let offset7 = offset6 + Int32(count6)
let offset8 = offset7 + Int32(count7)
let offset9 = offset8 + Int32(count8)
let result = (
T0.init(_owning: buffer.advanced(by: Int(offset0)), count: count0),
T1.init(_owning: buffer.advanced(by: Int(offset1)), count: count1),
T2.init(_owning: buffer.advanced(by: Int(offset2)), count: count2),
T3.init(_owning: buffer.advanced(by: Int(offset3)), count: count3),
T4.init(_owning: buffer.advanced(by: Int(offset4)), count: count4),
T5.init(_owning: buffer.advanced(by: Int(offset5)), count: count5),
T6.init(_owning: buffer.advanced(by: Int(offset6)), count: count6),
T7.init(_owning: buffer.advanced(by: Int(offset7)), count: count7),
T8.init(_owning: buffer.advanced(by: Int(offset8)), count: count8),
T9.init(_owning: buffer.advanced(by: Int(offset9)), count: count9))
buffer.deallocate()
return result
}
}