col2im_driver.cpp 16.7 KB
Newer Older
Chao Liu's avatar
Chao Liu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <numeric>
#include <initializer_list>
#include <cstdlib>
#include <stdlib.h>
#include "config.hpp"
#include "print.hpp"
#include "device.hpp"
#include "host_tensor_generator.hpp"
#include "conv_common.hpp"
#include "host_conv.hpp"
#include "device_tensor.hpp"
#include "host_col2im.hpp"
#include "device_col2im_eb_nchw.hpp"
Chao Liu's avatar
Chao Liu committed
15
#include "device_dynamic_col2im_gemmkgemmn_nchw.hpp"
Chao Liu's avatar
Chao Liu committed
16
17
18
19
20

int main(int argc, char* argv[])
{
    using namespace ck;

Chao Liu's avatar
testing  
Chao Liu committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#if 1
    // 1x1, 8x8
    constexpr index_t N  = 2;
    constexpr index_t C  = 128;
    constexpr index_t HI = 8;
    constexpr index_t WI = 8;
    constexpr index_t K  = 128;
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
37
38
39
40
41
    // 3x3, 71x71
    constexpr index_t N  = 128;
    constexpr index_t C  = 192;
    constexpr index_t HI = 71;
    constexpr index_t WI = 71;
Chao Liu's avatar
Chao Liu committed
42
43
44
45
    constexpr index_t K  = 128;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

Chao Liu's avatar
Chao Liu committed
46
    using ConvStrides   = Sequence<2, 2>;
Chao Liu's avatar
Chao Liu committed
47
48
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
49
50
    using LeftPads  = Sequence<1, 1>;
    using RightPads = Sequence<1, 1>;
Chao Liu's avatar
testing  
Chao Liu committed
51
#elif 1
Chao Liu's avatar
Chao Liu committed
52
53
    // 1x1, 8x8
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
54
55
56
57
58
59
60
61
62
63
64
65
66
    constexpr index_t C  = 1536;
    constexpr index_t HI = 8;
    constexpr index_t WI = 8;
    constexpr index_t K  = 256;
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
67
    // 1x1, 73x73
Chao Liu's avatar
Chao Liu committed
68
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
69
70
71
72
    constexpr index_t C  = 160;
    constexpr index_t HI = 73;
    constexpr index_t WI = 73;
    constexpr index_t K  = 64;
Chao Liu's avatar
Chao Liu committed
73
74
75
76
77
78
79
80
81
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
82
    // 3x3, 35x35
Chao Liu's avatar
Chao Liu committed
83
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
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
    constexpr index_t C  = 96;
    constexpr index_t HI = 35;
    constexpr index_t WI = 35;
    constexpr index_t K  = 96;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<1, 1>;
    using RightPads = Sequence<1, 1>;
#elif 0
    // 3x3, 71x71
    constexpr index_t N  = 128;
    constexpr index_t C  = 192;
    constexpr index_t HI = 71;
    constexpr index_t WI = 71;
    constexpr index_t K  = 192;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<2, 2>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<1, 1>;
    using RightPads = Sequence<1, 1>;
#elif 0
    // 7x1, 17x17
    constexpr index_t N  = 128;
    constexpr index_t C  = 128;
    constexpr index_t HI = 17;
    constexpr index_t WI = 17;
    constexpr index_t K  = 128;
    constexpr index_t Y  = 7;
Chao Liu's avatar
Chao Liu committed
119
120
121
122
123
    constexpr index_t X  = 1;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
124
125
    using LeftPads  = Sequence<3, 0>;
    using RightPads = Sequence<3, 0>;
Chao Liu's avatar
testing  
Chao Liu committed
126
#elif 1
Chao Liu's avatar
Chao Liu committed
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
    // 1x7, 17x17
    constexpr index_t N  = 128;
    constexpr index_t C  = 128;
    constexpr index_t HI = 17;
    constexpr index_t WI = 17;
    constexpr index_t K  = 128;
    constexpr index_t Y  = 1;
    constexpr index_t X  = 7;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 3>;
    using RightPads = Sequence<0, 3>;
#elif 0
    // 3x3, 299x299 stride=2
    constexpr index_t N  = 128;
    constexpr index_t C  = 3;
    constexpr index_t HI = 299;
    constexpr index_t WI = 299;
    constexpr index_t K  = 32;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<2, 2>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
154
155
156
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
157
    // 3x3, 147x147
Chao Liu's avatar
Chao Liu committed
158
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
    constexpr index_t C  = 32;
    constexpr index_t HI = 147;
    constexpr index_t WI = 147;
    constexpr index_t K  = 64;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<1, 1>;
    using RightPads = Sequence<1, 1>;
#elif 0
    // 3x3, 149x149
    constexpr index_t N  = 128;
    constexpr index_t C  = 32;
    constexpr index_t HI = 149;
    constexpr index_t WI = 149;
    constexpr index_t K  = 32;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;
Chao Liu's avatar
Chao Liu committed
180
181
182
183
184
185
186

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
187
    // 3x3, 17x17, stride 2
Chao Liu's avatar
Chao Liu committed
188
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
    constexpr index_t C  = 192;
    constexpr index_t HI = 17;
    constexpr index_t WI = 17;
    constexpr index_t K  = 192;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<2, 2>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
    // 1x1, 35x35
    constexpr index_t N  = 128;
    constexpr index_t C  = 384;
    constexpr index_t HI = 35;
    constexpr index_t WI = 35;
    constexpr index_t K  = 96;
Chao Liu's avatar
Chao Liu committed
208
209
210
211
212
213
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
214
215
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
testing  
Chao Liu committed
216
#elif 0
Chao Liu's avatar
Chao Liu committed
217
218
219
220
221
222
223
224
225
226
227
228
    // 3x3, 35x35, stride 2
    constexpr index_t N  = 128;
    constexpr index_t C  = 256;
    constexpr index_t HI = 35;
    constexpr index_t WI = 35;
    constexpr index_t K  = 384;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<2, 2>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
229
230
231
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
232
233
234
    // 1x3, 8x8
    constexpr index_t N  = 128;
    constexpr index_t C  = 384;
Chao Liu's avatar
Chao Liu committed
235
236
    constexpr index_t HI = 8;
    constexpr index_t WI = 8;
Chao Liu's avatar
Chao Liu committed
237
    constexpr index_t K  = 448;
Chao Liu's avatar
Chao Liu committed
238
    constexpr index_t Y  = 1;
Chao Liu's avatar
Chao Liu committed
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 1>;
    using RightPads = Sequence<0, 1>;
#elif 0
    // 3x1, 8x8
    constexpr index_t N  = 128;
    constexpr index_t C  = 448;
    constexpr index_t HI = 8;
    constexpr index_t WI = 8;
    constexpr index_t K  = 512;
    constexpr index_t Y  = 3;
Chao Liu's avatar
Chao Liu committed
254
255
256
257
258
    constexpr index_t X  = 1;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
    using LeftPads  = Sequence<1, 0>;
    using RightPads = Sequence<1, 0>;
#elif 0
    // 3x3, 147x147
    constexpr index_t N  = 128;
    constexpr index_t C  = 64;
    constexpr index_t HI = 147;
    constexpr index_t WI = 147;
    constexpr index_t K  = 96;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<2, 2>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
274
275
276
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
277
    // 7x1, 73x73
Chao Liu's avatar
Chao Liu committed
278
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
279
280
281
282
283
    constexpr index_t C  = 64;
    constexpr index_t HI = 73;
    constexpr index_t WI = 73;
    constexpr index_t K  = 64;
    constexpr index_t Y  = 7;
Chao Liu's avatar
Chao Liu committed
284
285
286
287
288
    constexpr index_t X  = 1;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
    using LeftPads  = Sequence<3, 0>;
    using RightPads = Sequence<3, 0>;
#elif 0
    // 3x3, 73x73
    constexpr index_t N  = 128;
    constexpr index_t C  = 64;
    constexpr index_t HI = 73;
    constexpr index_t WI = 73;
    constexpr index_t K  = 96;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
304
305
306
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
307
    // 1x1, 14x14, stride 2
Chao Liu's avatar
Chao Liu committed
308
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
309
310
311
312
    constexpr index_t C  = 1024;
    constexpr index_t HI = 14;
    constexpr index_t WI = 14;
    constexpr index_t K  = 2048;
Chao Liu's avatar
Chao Liu committed
313
314
315
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;

Chao Liu's avatar
Chao Liu committed
316
    using ConvStrides   = Sequence<2, 2>;
Chao Liu's avatar
Chao Liu committed
317
318
319
320
321
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
322
    // 1x1, 14x14
Chao Liu's avatar
Chao Liu committed
323
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
324
325
326
327
    constexpr index_t C  = 1024;
    constexpr index_t HI = 14;
    constexpr index_t WI = 14;
    constexpr index_t K  = 256;
Chao Liu's avatar
Chao Liu committed
328
329
330
331
332
333
334
335
336
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
337
    // 1x1, 14x14, stride 2
Chao Liu's avatar
Chao Liu committed
338
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
339
    constexpr index_t C  = 1024;
Chao Liu's avatar
Chao Liu committed
340
341
    constexpr index_t HI = 14;
    constexpr index_t WI = 14;
Chao Liu's avatar
Chao Liu committed
342
    constexpr index_t K  = 512;
Chao Liu's avatar
Chao Liu committed
343
344
345
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;

Chao Liu's avatar
Chao Liu committed
346
    using ConvStrides   = Sequence<2, 2>;
Chao Liu's avatar
Chao Liu committed
347
348
349
350
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#elif 1
    // 3x3, 28x28
    constexpr index_t N  = 128;
    constexpr index_t C  = 192;
    constexpr index_t HI = 28;
    constexpr index_t WI = 28;
    constexpr index_t K  = 128;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<1, 1>;
    using RightPads = Sequence<1, 1>;
Chao Liu's avatar
Chao Liu committed
366
#elif 0
Chao Liu's avatar
Chao Liu committed
367
    // 3x3, 14x14
Chao Liu's avatar
Chao Liu committed
368
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
369
    constexpr index_t C  = 256;
Chao Liu's avatar
Chao Liu committed
370
371
372
    constexpr index_t HI = 14;
    constexpr index_t WI = 14;
    constexpr index_t K  = 256;
Chao Liu's avatar
Chao Liu committed
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<1, 1>;
    using RightPads = Sequence<1, 1>;
#elif 0
    // 1x1, 56x56, stride 2
    constexpr index_t N  = 128;
    constexpr index_t C  = 256;
    constexpr index_t HI = 56;
    constexpr index_t WI = 56;
    constexpr index_t K  = 128;
Chao Liu's avatar
Chao Liu committed
388
389
390
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;

Chao Liu's avatar
Chao Liu committed
391
    using ConvStrides   = Sequence<2, 2>;
Chao Liu's avatar
Chao Liu committed
392
393
394
395
396
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
397
    // 7x7, 230x230 stride=2
Chao Liu's avatar
Chao Liu committed
398
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
    constexpr index_t C  = 3;
    constexpr index_t HI = 230;
    constexpr index_t WI = 230;
    constexpr index_t K  = 64;
    constexpr index_t Y  = 7;
    constexpr index_t X  = 7;

    using ConvStrides   = Sequence<2, 2>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
    // 1x1, 28x28, stride = 2
    constexpr index_t N  = 128;
    constexpr index_t C  = 512;
    constexpr index_t HI = 28;
    constexpr index_t WI = 28;
    constexpr index_t K  = 1024;
Chao Liu's avatar
Chao Liu committed
418
419
420
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;

Chao Liu's avatar
Chao Liu committed
421
    using ConvStrides   = Sequence<2, 2>;
Chao Liu's avatar
Chao Liu committed
422
423
424
425
426
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
427
    // 1x1, 28x28, stride 2
Chao Liu's avatar
Chao Liu committed
428
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
429
430
431
432
433
434
    constexpr index_t C  = 512;
    constexpr index_t HI = 28;
    constexpr index_t WI = 28;
    constexpr index_t K  = 256;
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;
Chao Liu's avatar
Chao Liu committed
435
436
437
438
439
440
441

    using ConvStrides   = Sequence<2, 2>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
Chao Liu's avatar
Chao Liu committed
442
    // 1x1, 7x7
Chao Liu's avatar
Chao Liu committed
443
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
444
    constexpr index_t C  = 512;
Chao Liu's avatar
Chao Liu committed
445
446
    constexpr index_t HI = 7;
    constexpr index_t WI = 7;
Chao Liu's avatar
Chao Liu committed
447
448
449
    constexpr index_t K  = 2048;
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;
Chao Liu's avatar
Chao Liu committed
450
451
452
453

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
454
455
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
456
#elif 0
Chao Liu's avatar
Chao Liu committed
457
    // 3x3, 7x7
Chao Liu's avatar
Chao Liu committed
458
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
459
460
461
462
463
464
    constexpr index_t C  = 512;
    constexpr index_t HI = 7;
    constexpr index_t WI = 7;
    constexpr index_t K  = 512;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;
Chao Liu's avatar
Chao Liu committed
465
466
467
468

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
469
470
471
472
    using LeftPads  = Sequence<1, 1>;
    using RightPads = Sequence<1, 1>;
#elif 0
    // 1x1, 56x56
Chao Liu's avatar
Chao Liu committed
473
    constexpr index_t N  = 128;
Chao Liu's avatar
Chao Liu committed
474
475
476
477
    constexpr index_t C  = 64;
    constexpr index_t HI = 56;
    constexpr index_t WI = 56;
    constexpr index_t K  = 64;
Chao Liu's avatar
Chao Liu committed
478
    constexpr index_t Y  = 1;
Chao Liu's avatar
Chao Liu committed
479
    constexpr index_t X  = 1;
Chao Liu's avatar
Chao Liu committed
480
481
482
483

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

Chao Liu's avatar
Chao Liu committed
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
    // 3x3, 56x56
    constexpr index_t N  = 128;
    constexpr index_t C  = 64;
    constexpr index_t HI = 56;
    constexpr index_t WI = 56;
    constexpr index_t K  = 64;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

    using ConvStrides   = Sequence<1, 1>;
    using ConvDilations = Sequence<1, 1>;

    using LeftPads  = Sequence<1, 1>;
    using RightPads = Sequence<1, 1>;
Chao Liu's avatar
Chao Liu committed
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
#endif

    constexpr auto img_nchw_desc = make_native_tensor_descriptor_packed(Sequence<N, C, HI, WI>{});
    constexpr auto wei_kcyx_desc = make_native_tensor_descriptor_packed(Sequence<K, C, Y, X>{});
    constexpr auto out_nkhw_desc = get_convolution_output_default_4d_tensor_descriptor(
        img_nchw_desc, wei_kcyx_desc, ConvStrides{}, ConvDilations{}, LeftPads{}, RightPads{});

    constexpr index_t HO = out_nkhw_desc.GetLengths()[2];
    constexpr index_t WO = out_nkhw_desc.GetLengths()[3];

    constexpr auto col_eb_desc =
        make_native_tensor_descriptor_packed(Sequence<C * Y * X, N * HO * WO>{});

    using FilterSizes = Sequence<Y, X>;
    using OutputSizes = Sequence<HO, WO>;

    ostream_tensor_descriptor(col_eb_desc, std::cout << "col_eb_desc: ");
    ostream_tensor_descriptor(img_nchw_desc, std::cout << "img_nchw_desc: ");
    print_array("FilterSizes", FilterSizes{});
    print_array("OutputSizes", OutputSizes{});
    print_array("LeftPads", LeftPads{});
    print_array("LeftPads", LeftPads{});
    print_array("RightPads", RightPads{});
    print_array("ConvStrides", ConvStrides{});
    print_array("ConvDilations", ConvDilations{});

    Tensor<float> col_eb(make_HostTensorDescriptor(col_eb_desc));
    Tensor<float> img_nchw_host(make_HostTensorDescriptor(img_nchw_desc));
    Tensor<float> img_nchw_device(make_HostTensorDescriptor(img_nchw_desc));

    std::size_t num_thread = std::thread::hardware_concurrency();

    if(argc != 3)
    {
        printf("arg1: do_verification, arg2: nrepeat\n");
        exit(1);
    }

    bool do_verification = atoi(argv[1]);
    std::size_t nrepeat  = atoi(argv[2]);

    if(do_verification)
    {
Chao Liu's avatar
testing  
Chao Liu committed
544
#if 1
Chao Liu's avatar
Chao Liu committed
545
546
547
548
549
550
        col_eb.GenerateTensorValue(GeneratorTensor_1{}, num_thread);
#else
        col_eb.GenerateTensorValue(GeneratorTensor_2{-5, 5}, num_thread);
#endif
    }

Chao Liu's avatar
testing  
Chao Liu committed
551
#if 0
Chao Liu's avatar
Chao Liu committed
552
553
554
555
556
557
558
559
560
561
562
    device_col2im_eb_nchw(col_eb_desc,
                          col_eb,
                          img_nchw_desc,
                          img_nchw_device,
                          FilterSizes{},
                          OutputSizes{},
                          ConvStrides{},
                          ConvDilations{},
                          LeftPads{},
                          RightPads{},
                          nrepeat);
563
#elif 1
Chao Liu's avatar
Chao Liu committed
564
565
566
567
568
569
570
571
572
573
574
575
576
    device_dynamic_col2im_gemmkgemmn_nchw(col_eb_desc,
                                          col_eb,
                                          img_nchw_desc,
                                          img_nchw_device,
                                          FilterSizes{},
                                          OutputSizes{},
                                          ConvStrides{},
                                          ConvDilations{},
                                          LeftPads{},
                                          RightPads{},
                                          nrepeat);
#endif

Chao Liu's avatar
Chao Liu committed
577
578
579
580
581
582
583
584
585
586
587
588
589
    if(do_verification)
    {
        host_col2im(col_eb,
                    img_nchw_host,
                    FilterSizes{},
                    OutputSizes{},
                    ConvStrides{},
                    ConvDilations{},
                    LeftPads{},
                    RightPads{});

        check_error(img_nchw_host, img_nchw_device);

Chao Liu's avatar
testing  
Chao Liu committed
590
#if 1
Chao Liu's avatar
Chao Liu committed
591
592
593
594
595
596
        LogRange(std::cout << "col_eb : ", col_eb.mData, ",") << std::endl;
        LogRange(std::cout << "img_nchw_host : ", img_nchw_host.mData, ",") << std::endl;
        LogRange(std::cout << "img_nchw_device : ", img_nchw_device.mData, ",") << std::endl;
#endif
    }
}