conv_driver.cpp 20.6 KB
Newer Older
Chao Liu's avatar
Chao Liu committed
1
#include <iostream>
Chao Liu's avatar
Chao Liu committed
2
3
#include <numeric>
#include <initializer_list>
Chao Liu's avatar
Chao Liu committed
4
#include <cstdlib>
Chao Liu's avatar
Chao Liu committed
5
#include <stdlib.h>
Chao Liu's avatar
Chao Liu committed
6
#include "config.hpp"
7
8
9
#include "ConstantTensorDescriptor_deprecated.hpp"
#include "print_array.hpp"
#include "print_sequence.hpp"
Chao Liu's avatar
Chao Liu committed
10
#include "device.hpp"
Chao Liu's avatar
Chao Liu committed
11
#include "tensor_generator.hpp"
Chao Liu's avatar
Chao Liu committed
12
#include "conv_common.hpp"
13
#include "host_conv.hpp"
Chao Liu's avatar
Chao Liu committed
14
#include "device_tensor.hpp"
Chao Liu's avatar
Chao Liu committed
15
//#include "device_convolution_direct_v2_nchw_kcyx_nkhw.hpp"
16
17
//#include "device_convolution_implicit_gemm_v1_chwn_cyxk_khwn.hpp"
//#include "device_convolution_implicit_gemm_v1_chwn_cyxk_khwn_padded.hpp"
18
19
20
//#include "device_convolution_implicit_gemm_v1_nchw_cyxk_nkhw.hpp"
//#include "device_convolution_implicit_gemm_v2_chwn_cyxk_khwn.hpp"
//#include "device_convolution_implicit_gemm_v3_nchw_cyxk_nkhw.hpp"
21
#include "device_convolution_implicit_gemm_v4r1_nchw_kcyx_nkhw_deprecated.hpp"
Chao Liu's avatar
Chao Liu committed
22
#include "device_convolution_implicit_gemm_v4r1_nchw_kcyx_nkhw.hpp"
23
24
//#include "device_convolution_implicit_gemm_v4r2_nchw_kcyx_nkhw.hpp"
//#include "device_convolution_implicit_gemm_v4r3_nchw_kcyx_nkhw.hpp"
25
#include "device_convolution_implicit_gemm_v4r4_nchw_kcyx_nkhw_deprecated.hpp"
Chao Liu's avatar
Chao Liu committed
26
#include "device_convolution_implicit_gemm_v4r4_nchw_kcyx_nkhw.hpp"
27

Chao Liu's avatar
Chao Liu committed
28
int main(int argc, char* argv[])
Chao Liu's avatar
Chao Liu committed
29
{
Chao Liu's avatar
Chao Liu committed
30
31
    using namespace ck;

32
#if 1
root's avatar
root committed
33
34
35
36
37
38
39
40
41
42
43
44
45
 // 1x1 for vector memory access , 7x7 image size
    constexpr index_t N  = 128;
    constexpr index_t C  = 256;
    constexpr index_t HI = 7;
    constexpr index_t WI = 7;
    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>;
46
47
48
#if CK_EXTEND_IMAGE_SIZE_PAD_W    
    using RightPads = Sequence<0, 1>;
#else
root's avatar
root committed
49
    using RightPads = Sequence<0, 0>;
50
#endif
root's avatar
root committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#elif 1
    // 1x1 for vector memory access, 13x13 image size
    constexpr index_t N  = 128;
    constexpr index_t C  = 256;//1024;
    constexpr index_t HI = 13;
    constexpr index_t WI = 13;
    constexpr index_t K  = 256;//2048;
    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
68
    // 1x1
69
70
71
72
73
    constexpr index_t N  = 64;
    constexpr index_t C  = 64;
    constexpr index_t HI = 56;
    constexpr index_t WI = 56;
    constexpr index_t K  = 256;
74
75
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;
Chao Liu's avatar
Chao Liu committed
76
77

    using ConvStrides   = Sequence<1, 1>;
78
    using ConvDilations = Sequence<1, 1>;
Chao Liu's avatar
Chao Liu committed
79

Chao Liu's avatar
Chao Liu committed
80
81
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#elif 0
    // 1x7
    constexpr index_t N  = 128;
    constexpr index_t C  = 1024;
    constexpr index_t HI = 17;
    constexpr index_t WI = 17;
    constexpr index_t K  = 1024;
    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
98
    // 3x3, 34x34
Chao Liu's avatar
Chao Liu committed
99
    constexpr index_t N  = 64;
100
    constexpr index_t C  = 256;
101
102
    constexpr index_t HI = 34;
    constexpr index_t WI = 34;
103
    constexpr index_t K  = 256;
104
105
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;
Chao Liu's avatar
Chao Liu committed
106

Chao Liu's avatar
Chao Liu committed
107
    using ConvStrides   = Sequence<1, 1>;
108
109
    using ConvDilations = Sequence<1, 1>;

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
#elif 0
    // 3x3 filter, 2x2 stride, 35x35 input, 17x17 output
    constexpr index_t N  = 128;
    constexpr index_t C  = 128;
    constexpr index_t HI = 35;
    constexpr index_t WI = 35;
    constexpr index_t K  = 128;
    constexpr index_t Y  = 3;
    constexpr index_t X  = 3;

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

125
126
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
127
#elif 0
Chao Liu's avatar
Chao Liu committed
128
    // 1x1 filter, 8x8 image
Chao Liu's avatar
Chao Liu committed
129
    // cudnn@V100 68%, ck@V100 72%, ck@P100 52%, ck@VII 42%
Chao Liu's avatar
Chao Liu committed
130
131
132
133
134
135
136
137
138
139
140
    constexpr index_t N  = 64;
    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>;

Chao Liu's avatar
Chao Liu committed
141
142
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
143
#elif 0
Chao Liu's avatar
Chao Liu committed
144
    // 1x1 filter, 8x8 image
Chao Liu's avatar
Chao Liu committed
145
    // cudnn@V100 77%, ck@V100 76%, ck@P100 79%, ck@VII 51%
Chao Liu's avatar
Chao Liu committed
146
147
148
149
150
151
152
153
154
155
156
    constexpr index_t N  = 128;
    constexpr index_t C  = 2048;
    constexpr index_t HI = 8;
    constexpr index_t WI = 8;
    constexpr index_t K  = 384;
    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
157
158
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
159
#elif 0
Chao Liu's avatar
Chao Liu committed
160
    // 1x1 filter, 7x7 image
Chao Liu's avatar
Chao Liu committed
161
    // cudnn@V100 82%, ck@V100 76%, ck@P100 67%, ck@VII 64%
Chao Liu's avatar
Chao Liu committed
162
163
164
165
166
167
168
169
170
171
172
    constexpr index_t N  = 128;
    constexpr index_t C  = 832;
    constexpr index_t HI = 7;
    constexpr index_t WI = 7;
    constexpr index_t K  = 384;
    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
173
174
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
175
#elif 0
Chao Liu's avatar
Chao Liu committed
176
    // 1x1 filter, 8x8 image
Chao Liu's avatar
Chao Liu committed
177
    // cudnn@V100 83%, ck@V100 75%, ck@P100 78%, ck@VII 65%
Chao Liu's avatar
Chao Liu committed
178
179
180
181
182
183
184
185
186
187
188
    constexpr index_t N  = 128;
    constexpr index_t C  = 1280;
    constexpr index_t HI = 8;
    constexpr index_t WI = 8;
    constexpr index_t K  = 384;
    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
189
190
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
191
#elif 0
Chao Liu's avatar
Chao Liu committed
192
    // 1x1 filter, 14x14 image
Chao Liu's avatar
Chao Liu committed
193
    // cudnn@V100 62%, ck@V100 68%, ck@P100 70%, ck@VII 50%
Chao Liu's avatar
Chao Liu committed
194
195
196
197
198
199
200
201
202
203
204
    constexpr index_t N  = 128;
    constexpr index_t C  = 512;
    constexpr index_t HI = 14;
    constexpr index_t WI = 14;
    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>;

Chao Liu's avatar
Chao Liu committed
205
206
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
207
#elif 0
Chao Liu's avatar
Chao Liu committed
208
    // 1x1 filter, 8x8 image
Chao Liu's avatar
Chao Liu committed
209
    // cudnn@V100 74%, ck@V100 57%, ck@P100 78%, ck@VII 61%
Chao Liu's avatar
Chao Liu committed
210
211
212
213
214
215
216
217
218
219
220
    constexpr index_t N  = 64;
    constexpr index_t C  = 1536;
    constexpr index_t HI = 8;
    constexpr index_t WI = 8;
    constexpr index_t K  = 384;
    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
221
222
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
223
#elif 0
Chao Liu's avatar
Chao Liu committed
224
    // 1x1 filter, 28x28 image
Chao Liu's avatar
Chao Liu committed
225
    // cudnn@V100 86%, ck@V100 84%, ck@P100 80%, ck@VII 69%
Chao Liu's avatar
Chao Liu committed
226
227
228
229
230
231
232
233
234
235
236
    constexpr index_t N  = 128;
    constexpr index_t C  = 256;
    constexpr index_t HI = 28;
    constexpr index_t WI = 28;
    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>;

Chao Liu's avatar
Chao Liu committed
237
238
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
239
#elif 0
Chao Liu's avatar
Chao Liu committed
240
    // 1x1 filter, 7x7 image
Chao Liu's avatar
Chao Liu committed
241
    // cudnn@V100 71%, ck@V100 55%, ck@P100 70%, ck@VII 62%
Chao Liu's avatar
Chao Liu committed
242
243
244
245
246
247
248
249
250
251
252
    constexpr index_t N  = 128;
    constexpr index_t C  = 832;
    constexpr index_t HI = 7;
    constexpr index_t WI = 7;
    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>;

Chao Liu's avatar
Chao Liu committed
253
254
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
255
#elif 0
Chao Liu's avatar
Chao Liu committed
256
    // 1x1 filter, 17x17 input
Chao Liu's avatar
Chao Liu committed
257
    // cudnn@V100 81%, ck@V100 76%, ck@P100 70%, ck@VII 76%
Chao Liu's avatar
Chao Liu committed
258
259
260
261
262
263
264
265
266
267
268
    constexpr index_t N  = 128;
    constexpr index_t C  = 768;
    constexpr index_t HI = 17;
    constexpr index_t WI = 17;
    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>;

Chao Liu's avatar
Chao Liu committed
269
270
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
271
#elif 0
Chao Liu's avatar
Chao Liu committed
272
    // 1x1 filter, 14x14 image
Chao Liu's avatar
Chao Liu committed
273
    // cudnn@V100 73%, ck@V100 71%, ck@P100 70%, ck@VII 64%
Chao Liu's avatar
Chao Liu committed
274
275
276
277
278
279
280
281
282
283
284
    constexpr index_t N  = 128;
    constexpr index_t C  = 528;
    constexpr index_t HI = 14;
    constexpr index_t WI = 14;
    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>;

Chao Liu's avatar
Chao Liu committed
285
286
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
287
288
#elif 0
    // 1x1 filter, 14x14 image
Chao Liu's avatar
Chao Liu committed
289
    // cudnn@V100 73%, ck@V100 72%, ck@P100 79%, ck@VII 75%
Chao Liu's avatar
Chao Liu committed
290
291
292
293
294
295
296
297
298
299
300
    constexpr index_t N  = 128;
    constexpr index_t C  = 528;
    constexpr index_t HI = 14;
    constexpr index_t WI = 14;
    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>;

Chao Liu's avatar
Chao Liu committed
301
302
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
Chao Liu's avatar
Chao Liu committed
303
#elif 0
Chao Liu's avatar
Chao Liu committed
304
    // 1x1 filter, 7x7 image
Chao Liu's avatar
Chao Liu committed
305
    // cudnn@V100 49%, ck@V100 50%, ck@P100 61%, ck@VII 52%
Chao Liu's avatar
Chao Liu committed
306
307
308
309
    constexpr index_t N  = 128;
    constexpr index_t C  = 832;
    constexpr index_t HI = 7;
    constexpr index_t WI = 7;
Chao Liu's avatar
Chao Liu committed
310
311
312
    constexpr index_t K  = 128;
    constexpr index_t Y  = 1;
    constexpr index_t X  = 1;
Chao Liu's avatar
Chao Liu committed
313
314
315
316

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

Chao Liu's avatar
Chao Liu committed
317
318
    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
319
#elif 0
Chao Liu's avatar
Chao Liu committed
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
    // 3x3 filter, 2x2 stride, 35x35 input, 17x17 output
    // cudnn@V100 90%, ck@V100 93%, ck@P100 83%, ck@VII 81%
    constexpr index_t N  = 128;
    constexpr index_t C  = 288;
    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>;

    using LeftPads  = Sequence<0, 0>;
    using RightPads = Sequence<0, 0>;
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#elif 0
    // 5x5 filter, 2x2 pad, 7x7 input
    constexpr index_t N  = 128;
    constexpr index_t C  = 48;
    constexpr index_t HI = 7;
    constexpr index_t WI = 7;
    constexpr index_t K  = 128;
    constexpr index_t Y  = 5;
    constexpr index_t X  = 5;

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

    using LeftPads  = Sequence<2, 2>;
    using RightPads = Sequence<2, 2>;
#elif 0
351
    // 1x7 filter, 0x3 pad, 17x17 input
352
353
354
355
356
    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;
357
358
    constexpr index_t Y  = 1;
    constexpr index_t X  = 7;
359
360
361
362

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

363
364
    using LeftPads  = Sequence<0, 3>;
    using RightPads = Sequence<0, 3>;
365
#elif 1
366
    // 7x1 filter, 3x0 pad, 17x17 input
367
368
369
370
371
    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;
372
373
    constexpr index_t Y  = 7;
    constexpr index_t X  = 1;
374
375
376
377

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

378
379
    using LeftPads  = Sequence<3, 0>;
    using RightPads = Sequence<3, 0>;
Chao Liu's avatar
Chao Liu committed
380
#endif
Chao Liu's avatar
Chao Liu committed
381

Chao Liu's avatar
Chao Liu committed
382
383
    auto in_nchw_desc  = make_ConstantTensorDescriptor_packed(Sequence<N, C, HI, WI>{});
    auto wei_kcyx_desc = make_ConstantTensorDescriptor_packed(Sequence<K, C, Y, X>{});
Chao Liu's avatar
Chao Liu committed
384
    auto out_nkhw_desc = get_convolution_output_default_4d_tensor_descriptor_deprecated(
Chao Liu's avatar
Chao Liu committed
385
        in_nchw_desc, wei_kcyx_desc, ConvStrides{}, ConvDilations{}, LeftPads{}, RightPads{});
386
387
388
389
#if CK_EXTEND_IMAGE_SIZE_PAD_W    
    auto out_nkhw_desc_nopadd = get_convolution_output_default_4d_tensor_descriptor_deprecated(
        in_nchw_desc, wei_kcyx_desc, ConvStrides{}, ConvDilations{}, LeftPads{}, Sequence<0,0>{});//RightPads{});
#endif
Chao Liu's avatar
Chao Liu committed
390

Chao Liu's avatar
Chao Liu committed
391
    ostream_ConstantTensorDescriptor(in_nchw_desc, std::cout << "in_nchw_desc: ");
Chao Liu's avatar
Chao Liu committed
392
    ostream_ConstantTensorDescriptor(wei_kcyx_desc, std::cout << "wei_kcyx_desc: ");
Chao Liu's avatar
Chao Liu committed
393
    ostream_ConstantTensorDescriptor(out_nkhw_desc, std::cout << "out_nkhw_desc: ");
394
395
396
397
    print_sequence("LeftPads", LeftPads{});
    print_sequence("RightPads", RightPads{});
    print_sequence("ConvStrides", ConvStrides{});
    print_sequence("ConvDilations", ConvDilations{});
Chao Liu's avatar
Chao Liu committed
398

Chao Liu's avatar
Chao Liu committed
399
400
    using in_data_t  = float;
    using out_data_t = float;
401
402
    Tensor<in_data_t> in_nchw(make_TensorDescriptor(in_nchw_desc));
    Tensor<in_data_t> wei_kcyx(make_TensorDescriptor(wei_kcyx_desc));
403
404
405
#if CK_EXTEND_IMAGE_SIZE_PAD_W   
    Tensor<out_data_t> out_nkhw_host(make_TensorDescriptor(out_nkhw_desc_nopadd));
#else
406
    Tensor<out_data_t> out_nkhw_host(make_TensorDescriptor(out_nkhw_desc));
407
#endif    
408
    Tensor<out_data_t> out_nkhw_device(make_TensorDescriptor(out_nkhw_desc));
Chao Liu's avatar
Chao Liu committed
409

Chao Liu's avatar
Chao Liu committed
410
    std::size_t num_thread = std::thread::hardware_concurrency();
Chao Liu's avatar
Chao Liu committed
411

Chao Liu's avatar
Chao Liu committed
412
413
414
415
416
417
418
    if(argc != 3)
    {
        printf("arg1: do_verification, arg2: nrepeat\n");
        exit(1);
    }

    bool do_verification = atoi(argv[1]);
Chao Liu's avatar
Chao Liu committed
419
    index_t nrepeat      = atoi(argv[2]);
420
421
422

    if(do_verification)
    {
Chao Liu's avatar
Chao Liu committed
423
#if 0
424
        in_nchw.GenerateTensorValue(GeneratorTensor_1{}, num_thread);
Chao Liu's avatar
Chao Liu committed
425
        wei_kcyx.GenerateTensorValue(GeneratorTensor_1{}, num_thread);
Chao Liu's avatar
Chao Liu committed
426
427
#elif 0
        in_nchw.GenerateTensorValue(GeneratorTensor_1{}, num_thread);
Chao Liu's avatar
bug fix  
Chao Liu committed
428
        wei_kcyx.GenerateTensorValue(GeneratorTensor_3{}, num_thread);
429
430
431
#elif 0
        in_nchw.GenerateTensorValue(GeneratorTensor_3{}, num_thread);
        wei_kcyx.GenerateTensorValue(GeneratorTensor_1{}, num_thread);
Chao Liu's avatar
Chao Liu committed
432
#elif 1
433
        in_nchw.GenerateTensorValue(GeneratorTensor_2{-5, 5}, num_thread);
Chao Liu's avatar
Chao Liu committed
434
        wei_kcyx.GenerateTensorValue(GeneratorTensor_2{-5, 5}, num_thread);
Chao Liu's avatar
Chao Liu committed
435
#elif 0
436
437
438
439
440
441
        in_nchw.GenerateTensorValue(GeneratorTensor_2{1, 5}, num_thread);

        auto gen_wei = [](auto... is) {
            return GeneratorTensor_2{1, 5}(is...) * GeneratorTensor_Checkboard{}(is...);
        };
        wei_kcyx.GenerateTensorValue(gen_wei, num_thread);
Chao Liu's avatar
Chao Liu committed
442
#endif
443
    }
Chao Liu's avatar
Chao Liu committed
444

Chao Liu's avatar
Chao Liu committed
445
#if 0
Chao Liu's avatar
Chao Liu committed
446
    device_convolution_direct_v2_nchw_kcyx_nkhw
Chao Liu's avatar
Chao Liu committed
447
        (in_nchw_desc, in_nchw, wei_kcyx_desc, wei_kcyx, out_nkhw_desc, out_nkhw_device, nrepeat);
Chao Liu's avatar
Chao Liu committed
448
#elif 0
Chao Liu's avatar
Chao Liu committed
449
    device_convolution_implicit_gemm_v1_chwn_cyxk_khwn(
Chao Liu's avatar
Chao Liu committed
450
        in_nchw_desc, in_nchw, wei_kcyx_desc, wei_kcyx, out_nkhw_desc, out_nkhw_device, nrepeat);
Chao Liu's avatar
Chao Liu committed
451
#elif 0
452
453
454
455
456
457
    device_convolution_implicit_gemm_v1_chwn_cyxk_khwn_padded(in_nchw_desc,
                                                              in_nchw,
                                                              wei_kcyx_desc,
                                                              wei_kcyx,
                                                              out_nkhw_desc,
                                                              out_nkhw_device,
Chao Liu's avatar
Chao Liu committed
458
459
                                                              LeftPads{},
                                                              RightPads{},
460
                                                              nrepeat);
Chao Liu's avatar
Chao Liu committed
461
#elif 0
Chao Liu's avatar
Chao Liu committed
462
    device_convolution_implicit_gemm_v1_nchw_cyxk_nkhw(
Chao Liu's avatar
Chao Liu committed
463
        in_nchw_desc, in_nchw, wei_kcyx_desc, wei_kcyx, out_nkhw_desc, out_nkhw_device, nrepeat);
464
#elif 0
Chao Liu's avatar
Chao Liu committed
465
    device_convolution_implicit_gemm_v2_chwn_cyxk_khwn(
Chao Liu's avatar
Chao Liu committed
466
        in_nchw_desc, in_nchw, wei_kcyx_desc, wei_kcyx, out_nkhw_desc, out_nkhw_device, nrepeat);
Chao Liu's avatar
Chao Liu committed
467
#elif 0
Chao Liu's avatar
Chao Liu committed
468
    device_convolution_implicit_gemm_v3_nchw_cyxk_nkhw(
Chao Liu's avatar
Chao Liu committed
469
        (in_nchw_desc, in_nchw, wei_kcyx_desc, wei_kcyx, out_nkhw_desc, out_nkhw_device, nrepeat);
470
471
472
473
474
475
476
477
478
479
#elif 0
    device_convolution_implicit_gemm_v4r1_nchw_kcyx_nkhw_deprecated(in_nchw_desc,
                                                                    in_nchw,
                                                                    wei_kcyx_desc,
                                                                    wei_kcyx,
                                                                    out_nkhw_desc,
                                                                    out_nkhw_device,
                                                                    ConvStrides{},
                                                                    ConvDilations{},
                                                                    nrepeat);
480
#elif 0
Chao Liu's avatar
Chao Liu committed
481
482
483
484
485
486
487
488
    device_convolution_implicit_gemm_v4r1_nchw_kcyx_nkhw(in_nchw_desc,
                                                         in_nchw,
                                                         wei_kcyx_desc,
                                                         wei_kcyx,
                                                         out_nkhw_desc,
                                                         out_nkhw_device,
                                                         ConvStrides{},
                                                         ConvDilations{},
489
490
                                                         LeftPads{},
                                                         RightPads{},
Chao Liu's avatar
Chao Liu committed
491
                                                         nrepeat);
Chao Liu's avatar
Chao Liu committed
492
#elif 0
Chao Liu's avatar
Chao Liu committed
493
494
495
496
497
498
    device_convolution_implicit_gemm_v4r2_nchw_kcyx_nkhw(in_nchw_desc,
                                                         in_nchw,
                                                         wei_kcyx_desc,
                                                         wei_kcyx,
                                                         out_nkhw_desc,
                                                         out_nkhw_device,
Chao Liu's avatar
Chao Liu committed
499
500
501
                                                         ConvStrides{},
                                                         ConvDilations{},
                                                         nrepeat);
Chao Liu's avatar
Chao Liu committed
502
#elif 0
Chao Liu's avatar
Chao Liu committed
503
504
505
506
507
508
    device_convolution_implicit_gemm_v4r3_nchw_kcyx_nkhw(in_nchw_desc,
                                                         in_nchw,
                                                         wei_kcyx_desc,
                                                         wei_kcyx,
                                                         out_nkhw_desc,
                                                         out_nkhw_device,
Chao Liu's avatar
Chao Liu committed
509
510
511
                                                         ConvStrides{},
                                                         ConvDilations{},
                                                         nrepeat);
Chao Liu's avatar
Chao Liu committed
512
#elif 0
513
514
515
516
517
518
519
520
521
    device_convolution_implicit_gemm_v4r4_nchw_kcyx_nkhw_deprecated(in_nchw_desc,
                                                                    in_nchw,
                                                                    wei_kcyx_desc,
                                                                    wei_kcyx,
                                                                    out_nkhw_desc,
                                                                    out_nkhw_device,
                                                                    ConvStrides{},
                                                                    ConvDilations{},
                                                                    nrepeat);
Chao Liu's avatar
Chao Liu committed
522
#elif 1
Chao Liu's avatar
Chao Liu committed
523
524
525
526
527
528
    device_convolution_implicit_gemm_v4r4_nchw_kcyx_nkhw(in_nchw_desc,
                                                         in_nchw,
                                                         wei_kcyx_desc,
                                                         wei_kcyx,
                                                         out_nkhw_desc,
                                                         out_nkhw_device,
Chao Liu's avatar
Chao Liu committed
529
530
                                                         ConvStrides{},
                                                         ConvDilations{},
531
532
                                                         LeftPads{},
                                                         RightPads{},
Chao Liu's avatar
Chao Liu committed
533
                                                         nrepeat);
534
#endif
Chao Liu's avatar
Chao Liu committed
535

536
    if(do_verification)
537
    {
Chao Liu's avatar
Chao Liu committed
538
#if 1
539
540
        if(Y == 3 && X == 3 && ConvStrides{}[0] == 1 && ConvStrides{}[1] == 1 &&
           ConvDilations{}[0] == 1 && ConvDilations{}[1] == 1)
541
        {
Chao Liu's avatar
Chao Liu committed
542
543
            host_winograd_3x3_convolution(
                in_nchw, wei_kcyx, out_nkhw_host, LeftPads{}, RightPads{});
544
545
        }
        else
Chao Liu's avatar
Chao Liu committed
546
#endif
547
        {
548
549
550
551
552
            host_direct_convolution(in_nchw,
                                    wei_kcyx,
                                    out_nkhw_host,
                                    ConvStrides{},
                                    ConvDilations{},
Chao Liu's avatar
Chao Liu committed
553
554
                                    LeftPads{},
                                    RightPads{});
555
556
        }
        check_error(out_nkhw_host, out_nkhw_device);
Chao Liu's avatar
Chao Liu committed
557

Chao Liu's avatar
Chao Liu committed
558
#if 0
559
        LogRange(std::cout << "in_nchw : ", in_nchw.mData, ",") << std::endl;
Chao Liu's avatar
Chao Liu committed
560
        LogRange(std::cout << "wei_kcyx: ", wei_kcyx.mData, ",") << std::endl;
561
562
        LogRange(std::cout << "out_nkhw_host  : ", out_nkhw_host.mData, ",") << std::endl;
        LogRange(std::cout << "out_nkhw_device: ", out_nkhw_device.mData, ",") << std::endl;
Chao Liu's avatar
Chao Liu committed
563
#endif
564
    }
565
}