-
Notifications
You must be signed in to change notification settings - Fork 2
/
dropblock-gpu.cu
568 lines (496 loc) · 30.3 KB
/
dropblock-gpu.cu
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
558
559
560
561
562
563
564
565
566
#include "./dropblock-gpu-inl.h"
namespace mxnet {
namespace op {
#define CUDA_1D_KERNEL_LOOP(i, n) \
for (size_t i = blockIdx.x * blockDim.x + threadIdx.x; i < (n); \
i += blockDim.x * gridDim.x)
using namespace mshadow::cuda;
// The maximum number of blocks to use in the default kernel call.
constexpr int ROI_MAXIMUM_NUM_BLOCKS = 4096;
/**
* @brief Compute the number of blocks needed to run N threads.
*/
inline int ROI_GET_BLOCKS(const int N) {
return std::max(
std::min(
(N + kMaxThreadsPerBlock - 1) / kMaxThreadsPerBlock,
ROI_MAXIMUM_NUM_BLOCKS),
// Use at least 1 block, since CUDA does not allow empty block
1);
}
template <typename T>
__global__ void DropblockForwardKernel(
const int nthreads,
const T* input_data,
T* output_data,
T* output_mask,
const int* dev_mask
) {
CUDA_1D_KERNEL_LOOP(index,nthreads){
//output_mask[index] = dev_mask[index] * (1.0f / pkeep);
output_mask[index] = dev_mask[index] ;
output_data[index] = output_mask[index] * input_data[index];
}
}
template<typename T>
__global__ void DropblockBackwardKernel(
const int N,//gdata.Size()
T* gdata,
const T* grad,
const T* mask
){
CUDA_1D_KERNEL_LOOP(index,N){
gdata[index]=grad[index]*mask[index];
}
}
template<typename xpu>
void DropblockForwardCompute(const nnvm::NodeAttrs& attrs,
const OpContext& ctx,
const std::vector<TBlob> &inputs,
const std::vector<OpReqType>& req,
const std::vector<TBlob> &outputs){
using namespace mshadow;
using namespace mshadow::expr;
const GPUDropblockParam param =nnvm::get<GPUDropblockParam>(attrs.parsed);
if (req[gpudropblock::kOut]!=kNullOp)
{
CHECK_EQ(inputs.size(),1U);
if(ctx.is_train)
{
CHECK_EQ(outputs.size(),2U);
}
Stream<gpu> *s=ctx.get_stream<gpu>();
const int count=inputs[gpudropblock::kData].Size();
const int num_batches=inputs[gpudropblock::kData].shape_[0];
const int channels=inputs[gpudropblock::kData].shape_[1];
const int height=inputs[gpudropblock::kData].shape_[2];
const int width=inputs[gpudropblock::kData].shape_[3];
const TBlob &out=outputs[gpudropblock::kOut];
cudaStream_t stream = mshadow::Stream<gpu>::GetStream(s);
if(ctx.is_train||(param.mode==gpudropblock::kAlways))
{
real_t pkeep=param.p;
static int iteration=0;
static float p_current=1.0;
if (p_current>pkeep)
{
++iteration;
p_current-=((p_current-pkeep)/5000.0)*iteration;
}
else{
p_current=pkeep;
}
const int blocksize=param.block_size;
index_t feat_size=height;
double gamma = ((1 - p_current) / (blocksize * blocksize)) * ((feat_size * feat_size) /((feat_size - blocksize + 1) *
(feat_size - blocksize + 1)));
index_t mask_reduction=blocksize/2;
index_t mask_height,mask_width;
if ((blocksize % 2) != 0) {
mask_height = height - mask_reduction * 2;
mask_width = width - mask_reduction * 2;
} else {
mask_height = height - mask_reduction * 2 + 1;
mask_width = width - mask_reduction * 2 + 1;
}
index_t mask_area = mask_height * mask_width;
index_t random_points_num = static_cast<int>(mask_area * gamma);
//实现np.arange()操作
std::vector<int> a;
for (int i = 0; i < mask_area; ++i) {
a.push_back(i);
}
std::vector<std::vector<std::vector<int>>> mask(num_batches, std::vector<std::vector<int >>(1,std::vector<int>(mask_area,
0)));
//实现random.sample(a,n)的操作
for(int i=0;i<random_points_num;)
{
index_t randnum=rand()%mask_area;
if(a[randnum]!=-100)
{
a[randnum]=-100;
++i;
}
}
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < mask_area; ++j) {
if (a[j] == -100) {
mask[i][0][j] = 1;
}
}
}
std::vector<std::vector<std::vector<std::vector<int>>>> mask_new(num_batches,
std::vector<std::vector<std::vector<int>>>(
1,
std::vector<std::vector<int>>(
mask_height,
std::vector<int>(
mask_width))));
//对应 mask=mask.reshape([data.shape[0], 1, mask_height, mask_width])
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < mask_area; ++k) {
index_t mask_i = k / mask_width;
index_t mask_j = k % mask_width;
mask_new[i][j][mask_i][mask_j] = mask[i][j][k];
}
}
}
//生成卷积所使用的weight_mat
std::vector<std::vector<std::vector<std::vector<int>>>> weight_mat(num_batches,
std::vector<std::vector<std::vector<int>>>(
1,
std::vector<std::vector<int>>(
blocksize,
std::vector<int>(
blocksize,
1))));
//卷积前的padding操作
//根据block_size的不同选择不同的padding策略
index_t padding=0;
if(blocksize==3)
{
padding=blocksize/2 +1;
}
else if (blocksize==5)
{
padding=ceil(blocksize/2.0)+1;
}
else if(blocksize>5)
{
padding=ceil(blocksize/2.0)+2;
}
index_t padding_height = mask_height + 2 * padding;
index_t padding_width = mask_width + 2 * padding;
std::vector<std::vector<std::vector<std::vector<int>>>> mask_padding(num_batches,
std::vector<std::vector<std::vector<int>>>(
1,
std::vector<std::vector<int>>(
padding_height,
std::vector<int>(
padding_width))));
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < padding_height; ++k) {
for (int l = 0; l < padding_width; ++l) {
if (k < padding || l < padding) {
mask_padding[i][j][k][l] = 0;
} else if (k > (mask_height + 1) || l > (mask_width + 1)) {
mask_padding[i][j][k][l] = 0;
} else {
mask_padding[i][j][k][l] = mask_new[i][j][k - padding][l - padding];
}
}
}
}
}
std::vector<std::vector<std::vector<int >>> mask_3d(num_batches, std::vector<std::vector<int >>(1,
std::vector<int >(
padding_height *
padding_width)));
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < padding_height; ++k) {
for (int l = 0; l < padding_width; ++l) {
mask_3d[i][j][l + k * padding_width] = mask_padding[i][j][k][l];
}
}
}
}
//把weightmat平铺为三维数组
std::vector<std::vector<std::vector<int>>> kernel_3d(num_batches, std::vector<std::vector<int>>(1,
std::vector<int>(
blocksize *
blocksize)));
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < blocksize; ++k) {
for (int l = 0; l < blocksize; ++l) {
kernel_3d[i][j][l + k * blocksize] = weight_mat[i][j][k][l];
}
}
}
}
//计算卷积输出矩阵的维数
index_t outm = padding_height - blocksize + 1;
//计算卷积过程中的被卷积矩阵的宽和高
index_t convAw = blocksize * blocksize;
index_t convAh = padding_height * padding_width;
//定义一个卷积过程中的矩阵
std::vector<std::vector<std::vector<int>>> A_convert(num_batches, std::vector<std::vector<int>>(1,
std::vector<int>(
convAh *
convAw)));
for (int n = 0; n < num_batches; ++n) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < outm; ++k) {
for (int m = 0; m < outm; ++m) {
index_t wh = k * outm * convAw + m * convAw;//k*9*9+m*121
index_t col1 = k * padding_height + m;//k*11+m 0
index_t col2 = (k + 1) * padding_height + m;//(k+1)*11+m 11
index_t col3 = (k + 2) * padding_height + m;//(k+2)*11+m 22
index_t col4 = (k + 3) * padding_height + m;//(k+3)*11+m
index_t col5 = (k + 4) * padding_height + m;//(k+4)*11+m
index_t col6 = (k + 5) * padding_height + m;
index_t col7 = (k + 6) * padding_height + m;
if (blocksize == 3) {
A_convert[n][j][wh] = mask_3d[n][j][col1];
A_convert[n][j][wh + 1] = mask_3d[n][j][col1 + 1];
A_convert[n][j][wh + 2] = mask_3d[n][j][col1 + 2];
A_convert[n][j][wh + 3] = mask_3d[n][j][col2];
A_convert[n][j][wh + 4] = mask_3d[n][j][col2 + 1];
A_convert[n][j][wh + 5] = mask_3d[n][j][col2 + 2];
A_convert[n][j][wh + 6] = mask_3d[n][j][col3];
A_convert[n][j][wh + 7] = mask_3d[n][j][col3 + 1];
A_convert[n][j][wh + 8] = mask_3d[n][j][col3 + 2];
} else if (blocksize == 5) {
A_convert[n][j][wh] = mask_3d[n][j][col1];
A_convert[n][j][wh + 1] = mask_3d[n][j][col1 + 1];
A_convert[n][j][wh + 2] = mask_3d[n][j][col1 + 2];
A_convert[n][j][wh + 3] = mask_3d[n][j][col1 + 3];
A_convert[n][j][wh + 4] = mask_3d[n][j][col1 + 4];
A_convert[n][j][wh + 5] = mask_3d[n][j][col2];
A_convert[n][j][wh + 6] = mask_3d[n][j][col2 + 1];
A_convert[n][j][wh + 7] = mask_3d[n][j][col2 + 2];
A_convert[n][j][wh + 8] = mask_3d[n][j][col2 + 3];
A_convert[n][j][wh + 9] = mask_3d[n][j][col2 + 4];
A_convert[n][j][wh + 10] = mask_3d[n][j][col3];
A_convert[n][j][wh + 11] = mask_3d[n][j][col3 + 1];
A_convert[n][j][wh + 12] = mask_3d[n][j][col3 + 2];
A_convert[n][j][wh + 13] = mask_3d[n][j][col3 + 3];
A_convert[n][j][wh + 14] = mask_3d[n][j][col3 + 4];
A_convert[n][j][wh + 15] = mask_3d[n][j][col4];
A_convert[n][j][wh + 16] = mask_3d[n][j][col4 + 1];
A_convert[n][j][wh + 17] = mask_3d[n][j][col4 + 2];
A_convert[n][j][wh + 18] = mask_3d[n][j][col4 + 3];
A_convert[n][j][wh + 19] = mask_3d[n][j][col4 + 4];
A_convert[n][j][wh + 20] = mask_3d[n][j][col5];
A_convert[n][j][wh + 21] = mask_3d[n][j][col5 + 1];
A_convert[n][j][wh + 22] = mask_3d[n][j][col5 + 2];
A_convert[n][j][wh + 23] = mask_3d[n][j][col5 + 3];
A_convert[n][j][wh + 24] = mask_3d[n][j][col5 + 4];
}else if (blocksize == 7) {
A_convert[n][j][wh] = mask_3d[n][j][col1];
A_convert[n][j][wh + 1] = mask_3d[n][j][col1 + 1];
A_convert[n][j][wh + 2] = mask_3d[n][j][col1 + 2];
A_convert[n][j][wh + 3] = mask_3d[n][j][col1 + 3];
A_convert[n][j][wh + 4] = mask_3d[n][j][col1 + 4];
A_convert[n][j][wh + 5] = mask_3d[n][j][col1 + 5];
A_convert[n][j][wh + 6] = mask_3d[n][j][col1 + 6];
A_convert[n][j][wh + 7] = mask_3d[n][j][col2];
A_convert[n][j][wh + 8] = mask_3d[n][j][col2 + 1];
A_convert[n][j][wh + 9] = mask_3d[n][j][col2 + 2];
A_convert[n][j][wh + 10] = mask_3d[n][j][col2 + 3];
A_convert[n][j][wh + 11] = mask_3d[n][j][col2 + 4];
A_convert[n][j][wh + 12] = mask_3d[n][j][col2 + 5];
A_convert[n][j][wh + 13] = mask_3d[n][j][col2 + 6];
A_convert[n][j][wh + 14] = mask_3d[n][j][col3];
A_convert[n][j][wh + 15] = mask_3d[n][j][col3 + 1];
A_convert[n][j][wh + 16] = mask_3d[n][j][col3 + 2];
A_convert[n][j][wh + 17] = mask_3d[n][j][col3 + 3];
A_convert[n][j][wh + 18] = mask_3d[n][j][col3 + 4];
A_convert[n][j][wh + 19] = mask_3d[n][j][col3 + 5];
A_convert[n][j][wh + 20] = mask_3d[n][j][col3 + 6];
A_convert[n][j][wh + 21] = mask_3d[n][j][col4];
A_convert[n][j][wh + 22] = mask_3d[n][j][col4 + 1];
A_convert[n][j][wh + 23] = mask_3d[n][j][col4 + 2];
A_convert[n][j][wh + 24] = mask_3d[n][j][col4 + 3];
A_convert[n][j][wh + 25] = mask_3d[n][j][col4 + 4];
A_convert[n][j][wh + 26] = mask_3d[n][j][col4 + 5];
A_convert[n][j][wh + 27] = mask_3d[n][j][col4 + 6];
A_convert[n][j][wh + 28] = mask_3d[n][j][col5];
A_convert[n][j][wh + 29] = mask_3d[n][j][col5 + 1];
A_convert[n][j][wh + 30] = mask_3d[n][j][col5 + 2];
A_convert[n][j][wh + 31] = mask_3d[n][j][col5 + 3];
A_convert[n][j][wh + 32] = mask_3d[n][j][col5 + 4];
A_convert[n][j][wh + 33] = mask_3d[n][j][col5 + 5];
A_convert[n][j][wh + 34] = mask_3d[n][j][col5 + 6];
A_convert[n][j][wh + 35] = mask_3d[n][j][col6];
A_convert[n][j][wh + 36] = mask_3d[n][j][col6 + 1];
A_convert[n][j][wh + 37] = mask_3d[n][j][col6 + 2];
A_convert[n][j][wh + 38] = mask_3d[n][j][col6 + 3];
A_convert[n][j][wh + 39] = mask_3d[n][j][col6 + 4];
A_convert[n][j][wh + 40] = mask_3d[n][j][col6 + 5];
A_convert[n][j][wh + 41] = mask_3d[n][j][col6 + 6];
A_convert[n][j][wh + 42] = mask_3d[n][j][col7];
A_convert[n][j][wh + 43] = mask_3d[n][j][col7 + 1];
A_convert[n][j][wh + 44] = mask_3d[n][j][col7 + 2];
A_convert[n][j][wh + 45] = mask_3d[n][j][col7 + 3];
A_convert[n][j][wh + 46] = mask_3d[n][j][col7 + 4];
A_convert[n][j][wh + 47] = mask_3d[n][j][col7 + 5];
A_convert[n][j][wh + 48] = mask_3d[n][j][col7 + 6];
}
}
}
}
}
std::vector<int> conv_cache;//存储卷积完了的数字
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < outm; ++k) {
for (int l = 0; l < outm; ++l) {
int result_one_position = 0;
index_t wh = k * outm * convAw + l * convAw;
for (int m = 0; m < convAw; ++m) {
result_one_position += A_convert[i][j][wh + m] * kernel_3d[i][j][m];
}
conv_cache.push_back(result_one_position);
}
}
}
}
//把卷积完了的数重组为4维数组
std::vector<std::vector<std::vector<std::vector<int>>>> mask_conved(num_batches,
std::vector<std::vector<std::vector<int>>>(
1,
std::vector<std::vector<int>>(
outm,
std::vector<int>(
outm))));
index_t delta = blocksize / 2;
index_t input_height = mask_height + delta * 2;
index_t input_width = mask_width + delta * 2;
index_t height_to_crop = outm - input_height;
index_t width_to_crop = outm - input_width;
if (height_to_crop != 0) {
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < outm - height_to_crop + 1; ++k) {
for (int l = 0; l < outm; ++l) {
mask_conved[i][j][k][l] = (conv_cache[i * outm * (outm - height_to_crop)
+ j * outm * (outm - height_to_crop) +
k * outm + l]==0)? 1:0;
}
}
}
}
}
if (width_to_crop != 0) {
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < outm; ++k) {
for (int l = 0; l < outm - width_to_crop + 1; ++l) {
mask_conved[i][j][k][l] =( conv_cache[i * outm * (outm - width_to_crop) +
j * outm * (outm - width_to_crop) +
k * (outm - width_to_crop) + l]==0)? 1:0;
}
}
}
}
}
if ((width_to_crop != 0)&&(height_to_crop!=0)) {
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < outm-height_to_crop+1; ++k) {
for (int l = 0; l < outm - width_to_crop + 1; ++l) {
mask_conved[i][j][k][l] =( conv_cache[i * (outm-height_to_crop) * (outm - width_to_crop) +
j * (outm-height_to_crop) * (outm - width_to_crop) +
k * (outm - width_to_crop) + l]==0)? 1:0;
}
}
}
}
}
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < 1; ++j) {
for (int k = 0; k < outm; ++k) {
for (int l = 0; l < outm; ++l) {
mask_conved[i][j][k][l] =(conv_cache[i * outm * outm + j * outm * outm + k * outm + l]==0)? 1:0;
}
}
}
}
//把mask_conved变为一个1D的数组来与indata进行计算
int mask_conved_1d[count];
int *dev_mask;
for (int i = 0; i < num_batches; ++i) {
for (int j = 0; j < channels; ++j) {
for (int k = 0; k < height; ++k) {
for (int l = 0; l < width; ++l) {
mask_conved_1d[i * channels * height * width
+ j * height * width +
k * width + l] = mask_conved[i][0][k][l];
}
}
}
}
//allocate memory on GPU
cudaMalloc((void**)&dev_mask,count* sizeof(int));
cudaMemcpy(dev_mask,mask_conved_1d,count* sizeof(int),cudaMemcpyHostToDevice);
MSHADOW_REAL_TYPE_SWITCH(inputs[0].type_flag_,DType,{
const DType *input_data=inputs[gpudropblock::kData].dptr<DType>();
DType *mask_out=outputs[gpudropblock::kMask].dptr<DType>();
DType *dropblock_out=outputs[gpudropblock::kOut].dptr<DType>();
DropblockForwardKernel<DType><<<ROI_GET_BLOCKS(count),kMaxThreadsPerBlock,0,stream>>>(
count,input_data,dropblock_out,mask_out,dev_mask
);
})
cudaFree (dev_mask);
}
else{
const TBlob& data = inputs[gpudropblock::kData];
if (req[gpudropblock::kOut] == kWriteTo) {
mxnet_op::copy(s, out, data);
} else {
MSHADOW_REAL_TYPE_SWITCH(inputs[0].type_flag_,DType,{MXNET_ASSIGN_REQ_SWITCH(req[gpudropblock::kOut], Req, {
mxnet_op::Kernel<mxnet_op::op_with_req<mshadow_op::identity, Req>, xpu>::Launch(
s, out.Size(), out.dptr<DType>(), data.dptr<DType>());//identity:input==output
});
})
}
}
}
}
template <typename xpu>
void DropblockBackwardCompute(const nnvm::NodeAttrs& attrs,
const OpContext& ctx,
const std::vector<TBlob> &inputs,
const std::vector<OpReqType> &req,
const std::vector<TBlob> &outputs){
CHECK_EQ(inputs.size(),2U);
CHECK_EQ(outputs.size(),1);
CHECK_EQ(req.size(),1);
using namespace mshadow;
using namespace mshadow::expr;
std::vector<TBlob> out_grads(2);
std::vector<TBlob> out_data(2);
out_grads[gpudropblock::kOut]=inputs[0];
out_data[gpudropblock::kMask]=inputs[1];
Stream<gpu> *s=ctx.get_stream<gpu>();
cudaStream_t stream = mshadow::Stream<gpu>::GetStream(s);
const GPUDropblockParam param =nnvm::get<GPUDropblockParam>(attrs.parsed);
if(ctx.is_train||param.mode==gpudropblock::kAlways)
{
const TBlob &gdata=outputs[gpudropblock::kData];
const TBlob &grad=out_grads[gpudropblock::kOut];
const TBlob &mask=out_data[gpudropblock::kMask];
const int count=inputs[gpudropblock::kData].Size();
MSHADOW_REAL_TYPE_SWITCH(inputs[0].type_flag_,DType,{
DropblockBackwardKernel<DType>
<<<ROI_GET_BLOCKS(count),
kMaxThreadsPerBlock,
0,
stream>>>(
count, gdata.dptr<DType>(),
grad.dptr<DType>(), mask.dptr<DType>()
);
})
}else{
const TBlob& gdata = outputs[gpudropblock::kData];
const TBlob& grad = out_grads[gpudropblock::kOut];
if (req[gpudropblock::kData] == kWriteTo) {
mxnet_op::copy(s, gdata, grad);
} else {
MSHADOW_REAL_TYPE_SWITCH(inputs[0].type_flag_,DType,{MXNET_ASSIGN_REQ_SWITCH(req[gpudropblock::kData], Req, {
mxnet_op::Kernel<mxnet_op::op_with_req<mshadow_op::identity, Req>, xpu>::Launch(
s, gdata.Size(), gdata.dptr<DType>(), grad.dptr<DType>());
});})
}
}
}
NNVM_REGISTER_OP(GPUDropblock)
.set_attr<FCompute>("FCompute<gpu>", DropblockForwardCompute<gpu>);
NNVM_REGISTER_OP(_backward_GPUDropblock)
.set_attr<FCompute>("FCompute<gpu>", DropblockBackwardCompute<gpu>);
} // namespace op
} // namespace mxnet