-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy pathconv_ocl_dir2Dfwd.cpp
496 lines (445 loc) · 23.2 KB
/
conv_ocl_dir2Dfwd.cpp
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
/*******************************************************************************
*
* MIT License
*
* Copyright (c) 2017 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
#include <miopen/handle.hpp>
#include <miopen/legacy_exhaustive_search.hpp>
#include <miopen/solver.hpp>
#include <miopen/env.hpp>
#include <miopen/conv/invokers/gen_x_w_y_pad.hpp>
MIOPEN_DECLARE_ENV_VAR(MIOPEN_DEBUG_CONV_DIRECT_OCL_FWD)
namespace miopen {
namespace solver {
bool ConvOclDirectFwd::IsApplicable(const ConvolutionContext& params) const
{
if(miopen::IsDisabled(MIOPEN_DEBUG_CONV_DIRECT_OCL_FWD{}))
return false;
if(!params.use_opencl_convolutions)
return false;
if(!params.Is2d())
return false;
if(!(params.direction.IsForward() || params.direction.IsBackwardData()))
return false;
if(params.IsAsymmetricPadH() || params.IsAsymmetricPadW())
return false;
if(!(params.IsFp32() || params.IsFp16() || params.IsBfp16()))
return false;
if(!params.IsLayoutDefault())
{
return false;
}
// clang-format off
// Cases when dy has negative padding are not supported (issue 918)
if(params.direction.IsBackwardData()
&& (params.GetBackwardPadW() < 0 || params.GetBackwardPadH() < 0))
return false;
// Factored out from ConvolutionDescriptor::IsDirectSupported(), which is now dissmissed:
if (params.group_counts == 1)
{
const auto& p = params; //alias
const bool supported =
((p.kernel_size_h == p.kernel_size_w)
&& (p.kernel_size_h == 3
|| p.kernel_size_h == 5
|| p.kernel_size_h == 7
|| p.kernel_size_h == 9
|| p.kernel_size_h == 11))
|| ((p.kernel_size_w == 10 || p.kernel_size_w == 20)
&& p.kernel_size_h == 5
&& p.kernel_stride_h == 2
&& p.kernel_stride_w == 2
&& p.pad_h == 0
&& p.pad_w == 0)
/// The following is for #1594. Most likely we can open more configs,
/// but that would require thorough testing.
|| (p.IsFp16()
&& p.kernel_size_h == 4
&& p.kernel_size_w == 4
&& p.pad_h == 0
&& p.pad_w == 0);
if (!supported)
return false;
}
return params.kernel_stride_w == params.kernel_stride_h
&& params.pad_w == params.pad_h
&& params.kernel_dilation_w == 1
&& params.kernel_dilation_h == 1
/// \todo need to make sure support stride > 2, should support but not tested
&& !(params.kernel_stride_w > 2 || params.kernel_stride_h > 2)
/// We have optimized 1x1 kernel for normal conv.
&& !(params.group_counts == 1 && params.kernel_size_h == 1 && params.kernel_size_w == 1)
/// \todo Workaround to avoid FP16 precision issue:
/// While MIOpenConvUni is up to 4x faster than MIOpenCDFGen (even not auto-tuned),
/// it seems that is has 4x..20x worse precision, and some "test_conv --half" tests fail.
/// See issue #1626.
&& !(params.direction.IsForward()
&& params.IsFp16()
&& params.kernel_stride_w == 2)
&& IsValidPerformanceConfig(params, GetDefaultPerformanceConfig(params));
// clang-format on
}
/// This prevents errors in ConvOclDirectFwd::GetSolution(),
/// or during OpenCL build. Reproduces logic from GetSolution()
/// and some logic from the corresponding opencl kernel source.
/// The cases which lead to errors can be later omitted from the search.
/// \todo Get rid the duplication of code where possible.
bool ConvOclDirectFwd::IsValidPerformanceConfig(
const ConvolutionContext& params, const LegacyPerformanceConfig& searched_params) const
{
ConvSolution result;
searched_params.CopyTo(result);
// auto pad_w = params.pad_w;
// auto pad_h = params.pad_h;
// auto hw_wave_sz = 64;
// if(!params.direction.IsForward())
// {
// // backward
// pad_w = params.kernel_size_w - 1 - pad_w;
// pad_h = params.kernel_size_h - 1 - pad_h;
// }
auto group_counts = params.group_counts;
result.n_in_data_tiles =
std::min(params.n_inputs / group_counts, searched_params.n_in_data_tiles);
result.n_out_pix_tiles =
std::min(params.n_outputs / group_counts, searched_params.n_out_pix_tiles);
// hacky fix of the incorrect kernel local memory address calculation for data
result.out_pix_tile1 = (!params.direction.IsForward() && params.kernel_stride_h > 1)
? params.kernel_stride_h
: searched_params.out_pix_tile1;
result.out_pix_tile0 = (!params.direction.IsForward() && params.kernel_stride_w > 1)
? params.kernel_stride_w
: searched_params.out_pix_tile0;
if(result.out_pix_tile1 == 0 || result.out_pix_tile0 == 0 /* DIV/0 */)
{
return false;
}
result.grp_tile0 = std::max(8, (result.in_tile0 / result.out_pix_tile0));
result.grp_tile1 = std::max(8, (result.in_tile1 / result.out_pix_tile1));
result.in_tile0 = result.grp_tile0 * result.out_pix_tile0;
result.in_tile1 = result.grp_tile1 * result.out_pix_tile1;
int alu_tile0 = (result.in_tile0 + result.out_pix_tile0 - 1) / result.out_pix_tile0;
int alu_tile1 = (result.in_tile1 + result.out_pix_tile1 - 1) / result.out_pix_tile1;
int alu_tiles_sz = (alu_tile0 * alu_tile1);
if(alu_tiles_sz > 256 || alu_tiles_sz == 0 /* DIV/0 */)
{
return false;
}
int n_alus_total = (result.grp_tile0 * result.grp_tile1);
result.n_stacks = std::min(result.n_stacks, (n_alus_total + alu_tiles_sz - 1) / alu_tiles_sz);
result.n_stacks = std::min(params.batch_sz, result.n_stacks);
if(result.n_stacks == 0 /* DIV/0 */)
{
return false;
}
int n_alus_perstack = (n_alus_total + result.n_stacks - 1) / result.n_stacks;
// int n_read_procs;
// if((result.grp_tile1 * result.grp_tile0) <= static_cast<float>(result.in_tile1 *
// result.in_tile0))
// {
// n_read_procs = result.grp_tile1 * result.grp_tile0;
// }
// else
// {
// float proc_data_ratio = static_cast<float>(result.in_tile1 * result.in_tile0) /
// static_cast<float>(result.grp_tile1 * result.grp_tile0);
// n_read_procs = (proc_data_ratio <= 0.25)
// ? (result.grp_tile1 * result.grp_tile0) / 4
// : (proc_data_ratio <= 0.5) ? (result.grp_tile1 * result.grp_tile0) / 2
// : (result.grp_tile1 * result.grp_tile0);
// }
// int n_out_tile_blocks0 = (params.out_width + result.in_tile0 - 1) / (result.in_tile0);
// int n_out_tile_blocks1 = (params.out_height + result.in_tile1 - 1) / (result.in_tile1);
int n_alu_tiles_perstack = (n_alus_perstack + alu_tiles_sz - 1) / alu_tiles_sz;
int n_out_tiles_perstack = n_alu_tiles_perstack * result.n_out_pix_tiles;
n_out_tiles_perstack = std::min(n_out_tiles_perstack, params.n_outputs / group_counts);
// const auto mlo_hw_wave_sz=hw_wave_sz;
const auto mlo_filter_size0 = static_cast<long long>(params.kernel_size_w);
const auto mlo_filter_size1 = static_cast<long long>(params.kernel_size_h);
// const auto mlo_filter_pad0=static_cast<long long>(pad_w);
// const auto mlo_filter_pad1=static_cast<long long>(pad_h);
const auto mlo_filter_stride0 = static_cast<long long>(params.kernel_stride_w);
const auto mlo_filter_stride1 = static_cast<long long>(params.kernel_stride_h);
// const auto mlo_n_outputs=static_cast<long long>(params.n_outputs);
// const auto mlo_n_inputs=static_cast<long long>(params.n_inputs);
// const auto mlo_batch_sz=static_cast<long long>(params.batch_sz);
// const auto mlo_out_width=static_cast<long long>(params.out_width);
// const auto mlo_out_height=static_cast<long long>(params.out_height);
// const auto mlo_out_batch_stride=static_cast<long long>(params.out_batch_stride);
// const auto mlo_out_channel_stride=static_cast<long long>(params.out_channel_stride);
// const auto mlo_out_stride=static_cast<long long>(params.out_stride);
// const auto mlo_in_width=static_cast<long long>(params.in_width);
// const auto mlo_in_height=static_cast<long long>(params.in_height);
// const auto mlo_in_batch_stride=static_cast<long long>(params.in_batch_stride);
// const auto mlo_in_channel_stride=static_cast<long long>(params.in_channel_stride);
// const auto mlo_in_stride=static_cast<long long>(params.in_stride);
// algorithm parameters
const auto mlo_in_tile0 = static_cast<long long>(result.in_tile0);
const auto mlo_in_tile1 = static_cast<long long>(result.in_tile1);
// const auto mlo_grp_tile0=static_cast<long long>(result.grp_tile0);
// const auto mlo_grp_tile1=static_cast<long long>(result.grp_tile1);
// const auto mlo_out_tile0=static_cast<long long>(result.out_pix_tile0);
// const auto mlo_out_tile1=static_cast<long long>(result.out_pix_tile1);
const auto mlo_n_stacks = static_cast<long long>(result.n_stacks);
// const auto mlo_n_out_tiles=static_cast<long long>(result.n_out_pix_tiles);
const auto mlo_n_out_tiles_perstack = static_cast<long long>(n_out_tiles_perstack);
const auto mlo_n_in_tiles_perstack = static_cast<long long>(result.n_in_data_tiles);
// const auto mlo_n_read_procs=static_cast<long long>(n_read_procs);
// const auto mlo_conv_bias=static_cast<long long>(params.bias);
// const auto mlo_alu_vtile0=static_cast<long long>(alu_tile0);
// const auto mlo_alu_vtile1=static_cast<long long>(alu_tile1);
if(n_out_tiles_perstack == 0 /* DIV/0 */)
{
return false;
}
// Reproduces some build logic (preprocessing computations) from the opencl source.
// Variables whose names begin with "mlo_" represent corresponding "MLO_" macros,
// e.g. mlo_in_lcl_width here represents MLO_IN_LCL_WIDTH macro in the opencl source.
long long mlo_in_lcl_width;
long long mlo_in_lcl_height;
if(params.direction.IsForward())
{
mlo_in_lcl_width = ((mlo_in_tile0 - 1) * mlo_filter_stride0 + mlo_filter_size0);
mlo_in_lcl_height = ((mlo_in_tile1 - 1) * mlo_filter_stride1 + mlo_filter_size1);
}
else
{
assert(mlo_filter_stride0 != 0 && mlo_filter_stride1 != 0);
mlo_in_lcl_width =
((mlo_in_tile0 + mlo_filter_size0 - 1 + mlo_filter_stride0 - 1) / mlo_filter_stride0);
mlo_in_lcl_height =
((mlo_in_tile1 + mlo_filter_size1 - 1 + mlo_filter_stride1 - 1) / mlo_filter_stride1);
}
const auto mlo_in_lcl_tile_sz = (mlo_in_lcl_width * mlo_in_lcl_height);
const auto mlo_in_lcl_perstack_sz = (mlo_in_lcl_tile_sz * mlo_n_in_tiles_perstack);
const auto mlo_in_lcl_sz = (mlo_in_lcl_perstack_sz * mlo_n_stacks);
const auto mlo_filter_sz = (mlo_filter_size1 * mlo_filter_size0);
const auto mlo_weights_sz =
(mlo_n_out_tiles_perstack * mlo_n_in_tiles_perstack * mlo_filter_sz);
const auto sizeof_float = GetTypeSize(params.in_data_type);
const auto mlo_lds_max_size = 65536;
// MIOPEN_LOG_I("((mlo_in_lcl_sz + mlo_weights_sz) * sizeof_float)=" << ((mlo_in_lcl_sz +
// mlo_weights_sz) * sizeof_float));
if(((mlo_in_lcl_sz + mlo_weights_sz) * sizeof_float) > mlo_lds_max_size)
{
return false; // NOLINT
}
return true;
}
inline ConvSolution BaseGetSolution(const ConvolutionContext& params,
const LegacyPerformanceConfig& searched_params)
{
ConvSolution result;
// std::size_t localMemSize = params.stream.GetLocalMemorySize();
searched_params.CopyTo(result);
auto pad_w = params.pad_w;
auto pad_h = params.pad_h;
auto group_counts = params.group_counts;
auto hw_wave_sz = 64;
// auto dev_local_mem_sz = localMemSize; // in bytes
if(!params.direction.IsForward())
{
// backward
pad_w = params.kernel_size_w - 1 - pad_w;
pad_h = params.kernel_size_h - 1 - pad_h;
}
result.n_in_data_tiles =
std::min(params.n_inputs / group_counts, searched_params.n_in_data_tiles);
result.n_out_pix_tiles =
std::min(params.n_outputs / group_counts, searched_params.n_out_pix_tiles);
// hacky fix of the incorrect kernel local memory address calculation for data
result.out_pix_tile1 = (!params.direction.IsForward() && params.kernel_stride_h > 1)
? params.kernel_stride_h
: searched_params.out_pix_tile1;
result.out_pix_tile0 = (!params.direction.IsForward() && params.kernel_stride_w > 1)
? params.kernel_stride_w
: searched_params.out_pix_tile0;
if(result.out_pix_tile1 == 0 || result.out_pix_tile0 == 0 /* DIV/0 */)
{
MIOPEN_LOG_E("result.out_pix_tile1 == 0 || result.out_pix_tile0 == 0");
return {miopenStatusInternalError};
}
result.grp_tile0 = std::max(8, (result.in_tile0 / result.out_pix_tile0));
result.grp_tile1 = std::max(8, (result.in_tile1 / result.out_pix_tile1));
result.in_tile0 = result.grp_tile0 * result.out_pix_tile0;
result.in_tile1 = result.grp_tile1 * result.out_pix_tile1;
int alu_tile0 = (result.in_tile0 + result.out_pix_tile0 - 1) / result.out_pix_tile0;
int alu_tile1 = (result.in_tile1 + result.out_pix_tile1 - 1) / result.out_pix_tile1;
int alu_tiles_sz = (alu_tile0 * alu_tile1);
if(alu_tiles_sz > 256 || alu_tiles_sz == 0 /* DIV/0 */)
{
MIOPEN_LOG_E("need out pix size ajustments (alu_tiles_sz > 256 || alu_tiles_sz == 0)");
return {miopenStatusInternalError};
}
int n_alus_total = (result.grp_tile0 * result.grp_tile1);
result.n_stacks = std::min(result.n_stacks, (n_alus_total + alu_tiles_sz - 1) / alu_tiles_sz);
result.n_stacks = std::min(params.batch_sz, result.n_stacks);
if(result.n_stacks == 0 /* DIV/0 */)
{
MIOPEN_LOG_E("result.n_stacks == 0");
return {miopenStatusInternalError};
}
int n_alus_perstack = (n_alus_total + result.n_stacks - 1) / result.n_stacks;
int n_read_procs;
if((result.grp_tile1 * result.grp_tile0) <= (result.in_tile1 * result.in_tile0))
{
n_read_procs = result.grp_tile1 * result.grp_tile0;
}
else
{
float proc_data_ratio = static_cast<float>(result.in_tile1 * result.in_tile0) /
static_cast<float>(result.grp_tile1 * result.grp_tile0);
n_read_procs = (proc_data_ratio <= 0.25)
? (result.grp_tile1 * result.grp_tile0) / 4
: (proc_data_ratio <= 0.5) ? (result.grp_tile1 * result.grp_tile0) / 2
: (result.grp_tile1 * result.grp_tile0);
}
int n_out_tile_blocks0 = (params.out_width + result.in_tile0 - 1) / (result.in_tile0);
int n_out_tile_blocks1 = (params.out_height + result.in_tile1 - 1) / (result.in_tile1);
int n_alu_tiles_perstack = (n_alus_perstack + alu_tiles_sz - 1) / alu_tiles_sz;
int n_out_tiles_perstack = n_alu_tiles_perstack * result.n_out_pix_tiles;
n_out_tiles_perstack = std::min(n_out_tiles_perstack, params.n_outputs / group_counts);
KernelInfo kernel_params;
kernel_params.comp_options =
std::string(" -DMLO_HW_WAVE_SZ=") + std::to_string(static_cast<long long>(hw_wave_sz)) +
std::string(" -DMLO_DIR_FORWARD=") + (params.direction.IsForward() ? "1" : "0") +
std::string(" -DMLO_FILTER_SIZE0=") +
std::to_string(static_cast<long long>(params.kernel_size_w)) +
std::string(" -DMLO_FILTER_SIZE1=") +
std::to_string(static_cast<long long>(params.kernel_size_h)) +
std::string(" -DMLO_FILTER_PAD0=") + std::to_string(static_cast<long long>(pad_w)) +
std::string(" -DMLO_FILTER_PAD1=") + std::to_string(static_cast<long long>(pad_h)) +
std::string(" -DMLO_FILTER_STRIDE0=") +
std::to_string(static_cast<long long>(params.kernel_stride_w)) +
std::string(" -DMLO_FILTER_STRIDE1=") +
std::to_string(static_cast<long long>(params.kernel_stride_h)) +
std::string(" -DMLO_N_OUTPUTS=") +
std::to_string(static_cast<long long>(params.n_outputs)) + std::string(" -DMLO_N_INPUTS=") +
std::to_string(static_cast<long long>(params.n_inputs)) + std::string(" -DMLO_BATCH_SZ=") +
std::to_string(static_cast<long long>(params.batch_sz)) + std::string(" -DMLO_OUT_WIDTH=") +
std::to_string(static_cast<long long>(params.out_width)) +
std::string(" -DMLO_OUT_HEIGHT=") +
std::to_string(static_cast<long long>(params.out_height)) +
std::string(" -DMLO_OUT_BATCH_STRIDE=") +
std::to_string(static_cast<long long>(params.out_batch_stride)) +
std::string(" -DMLO_OUT_CHANNEL_STRIDE=") +
std::to_string(static_cast<long long>(params.out_channel_stride)) +
std::string(" -DMLO_OUT_STRIDE=") +
std::to_string(static_cast<long long>(params.out_stride)) +
std::string(" -DMLO_IN_WIDTH=") + std::to_string(static_cast<long long>(params.in_width)) +
std::string(" -DMLO_IN_HEIGHT=") +
std::to_string(static_cast<long long>(params.in_height)) +
std::string(" -DMLO_IN_BATCH_STRIDE=") +
std::to_string(static_cast<long long>(params.in_batch_stride)) +
std::string(" -DMLO_IN_CHANNEL_STRIDE=") +
std::to_string(static_cast<long long>(params.in_channel_stride)) +
std::string(" -DMLO_IN_STRIDE=") +
std::to_string(static_cast<long long>(params.in_stride))
// algorithm parameters
+ std::string(" -DMLO_IN_TILE0=") +
std::to_string(static_cast<long long>(result.in_tile0)) // size of input data per ALU plane
+ std::string(" -DMLO_IN_TILE1=") +
std::to_string(static_cast<long long>(result.in_tile1)) // size of input data per ALU plane
+ std::string(" -DMLO_GRP_TILE0=") +
std::to_string(static_cast<long long>(result.grp_tile0)) // # of ALUs (group size)
+ std::string(" -DMLO_GRP_TILE1=") +
std::to_string(static_cast<long long>(result.grp_tile1)) //
+ std::string(" -DMLO_OUT_TILE0=") +
std::to_string(
static_cast<long long>(result.out_pix_tile0)) // size of ouptput tile per wk-item (ALU))
+ std::string(" -DMLO_OUT_TILE1=") +
std::to_string(static_cast<long long>(result.out_pix_tile1)) //
+ std::string(" -DMLO_N_STACKS=") +
std::to_string(static_cast<long long>(result.n_stacks)) // # of diff stacks (part of batch).
+ std::string(" -DMLO_N_OUT_TILES=") +
std::to_string(static_cast<long long>(
result.n_out_pix_tiles)) // # output pixel tiles per wk-item (ALU)
+ std::string(" -DMLO_N_OUT_TILES_PERSTACK=") +
std::to_string(static_cast<long long>(n_out_tiles_perstack)) +
std::string(" -DMLO_N_IN_TILES_PERSTACK=") +
std::to_string(static_cast<long long>(
result.n_in_data_tiles)) // total # of blocks of different inputs in LDS
+ std::string(" -DMLO_N_READ_PROCS=") +
std::to_string(static_cast<long long>(n_read_procs)) + std::string(" -DMLO_ALU_VTILE0=") +
std::to_string(static_cast<long long>(alu_tile0)) + std::string(" -DMLO_ALU_VTILE1=") +
std::to_string(static_cast<long long>(alu_tile1)) + params.general_compile_options;
if(group_counts >= 2)
{
kernel_params.comp_options += (std::string(" -DMLO_GROUP_COUNTS=") +
std::to_string(static_cast<long long>(group_counts)));
kernel_params.comp_options +=
(std::string(" -DMLO_GROUP_TILES=") +
std::to_string(static_cast<long long>(params.n_outputs / group_counts)));
kernel_params.comp_options +=
(std::string(" -DMLO_STACK_PERGROUP=") +
std::to_string(static_cast<long long>(
(params.n_outputs / group_counts + n_out_tiles_perstack - 1) /
n_out_tiles_perstack)));
kernel_params.comp_options += std::string(" -DGRP_MOD_ENABLE");
}
kernel_params.l_wk.push_back(result.grp_tile1 * result.grp_tile0);
kernel_params.l_wk.push_back(1);
kernel_params.l_wk.push_back(1);
size_t gbl_wk0 = n_out_tile_blocks0 * n_out_tile_blocks1;
if(n_out_tiles_perstack == 0 /* DIV/0 */)
{
MIOPEN_LOG_E("n_out_tiles_perstack == 0");
return {miopenStatusInternalError};
}
size_t gbl_wk1 = group_counts >= 2
? (((params.n_outputs / group_counts + n_out_tiles_perstack - 1) /
n_out_tiles_perstack) *
group_counts)
: ((params.n_outputs + n_out_tiles_perstack - 1) / n_out_tiles_perstack);
size_t gbl_wk2 = (params.batch_sz + result.n_stacks - 1) / result.n_stacks;
kernel_params.g_wk.push_back(gbl_wk0 * kernel_params.l_wk[0]);
kernel_params.g_wk.push_back(gbl_wk1);
kernel_params.g_wk.push_back(gbl_wk2);
kernel_params.kernel_file = "MIOpenConvDirUni.cl";
kernel_params.kernel_name = "MIOpenConvUni";
result.construction_params.push_back(kernel_params);
result.invoker_factory = &conv::MakeGenericXWYPadInvoker;
if(params.direction.IsForward())
result.invoker_factory = &conv::MakeGenericXWYPadInvoker;
return result;
}
ConvSolution ConvOclDirectFwd::GetSolution(const ConvolutionContext& params,
const LegacyPerformanceConfig& searched_params) const
{
ConvSolution result = BaseGetSolution(params, searched_params);
if(result.Succeeded())
{
result.construction_params[0].comp_options +=
std::string(" -DMLO_CONV_BIAS=") + std::to_string(static_cast<long long>(params.bias));
}
return result;
}
ConvSolution
ConvOclDirectFwdFused::GetSolution(const ConvolutionContext& params,
const LegacyPerformanceConfig& searched_params) const
{
ConvSolution result = BaseGetSolution(params, searched_params);
return result;
}
} // namespace solver
} // namespace miopen