aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/eigen_benchmark_cpu_test.cc
blob: 3b34f650b6b89ba63dc8c82b49c2f3a5b9b9a2a5 (plain)
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
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENTE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONT OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#define EIGEN_USE_CUSTOM_THREAD_POOL
#define EIGEN_USE_THREADS

#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/kernels/eigen_benchmark.h"
#include "tensorflow/core/platform/test_benchmark.h"

#define CREATE_THREAD_POOL(threads) \
  Eigen::ThreadPool tp(threads);    \
  Eigen::ThreadPoolDevice device(&tp, threads)

// -------------------------------------------------------------------------- //
// Spatial Convolutions                                                       //
// -------------------------------------------------------------------------- //

void SpatialConvolution(int iters, int num_threads,
                        /* Input dimensions: */
                        int input_batches, int input_height, int input_width,
                        int input_depth,
                        /* Filter (kernel) dimensions: */
                        int filter_count, int filter_height, int filter_width) {
  ::tensorflow::testing::StopTiming();

  CREATE_THREAD_POOL(num_threads);

  using Benchmark =
      SpatialConvolutionBenchmarksSuite<float, Eigen::ThreadPoolDevice>;
  auto benchmark = Benchmark(iters, device);

  typename Benchmark::Dimensions input_dims(input_batches, input_height,
                                            input_width, input_depth);
  typename Benchmark::Dimensions filter_dims(filter_height, filter_width,
                                             input_depth, filter_count);

  benchmark.SpatialConvolution(input_dims, filter_dims);

  auto output_size = input_dims.TotalSize();
  auto flops = output_size * (input_depth * filter_height * filter_width);
  ::tensorflow::testing::ItemsProcessed(flops * iters);
}

void SpatialConvolutionBackwardInput(int iters, int num_threads,
                                     /* Input dimensions: */
                                     int input_batches, int input_height,
                                     int input_width, int input_depth,
                                     /* Filter (kernel) dimensions: */
                                     int filter_count, int filter_height,
                                     int filter_width) {
  ::tensorflow::testing::StopTiming();

  CREATE_THREAD_POOL(num_threads);

  using Benchmark =
      SpatialConvolutionBenchmarksSuite<float, Eigen::ThreadPoolDevice>;
  auto benchmark = Benchmark(iters, device);

  typename Benchmark::Dimensions input_dims(input_batches, input_height,
                                            input_width, input_depth);
  typename Benchmark::Dimensions filter_dims(filter_height, filter_width,
                                             input_depth, filter_count);

  benchmark.SpatialConvolutionBackwardInput(input_dims, filter_dims);

  auto output_size = input_dims.TotalSize();
  auto flops = output_size * (input_depth * filter_height * filter_width);
  ::tensorflow::testing::ItemsProcessed(flops * iters);
}

void SpatialConvolutionBackwardKernel(int iters, int num_threads,
                                      /* Input dimensions: */
                                      int input_batches, int input_height,
                                      int input_width, int input_depth,
                                      /* Filter (kernel) dimensions: */
                                      int filter_count, int filter_height,
                                      int filter_width) {
  ::tensorflow::testing::StopTiming();

  CREATE_THREAD_POOL(num_threads);

  using Benchmark =
      SpatialConvolutionBenchmarksSuite<float, Eigen::ThreadPoolDevice>;
  auto benchmark = Benchmark(iters, device);

  typename Benchmark::Dimensions input_dims(input_batches, input_height,
                                            input_width, input_depth);
  typename Benchmark::Dimensions filter_dims(filter_height, filter_width,
                                             input_depth, filter_count);

  benchmark.SpatialConvolutionBackwardKernel(input_dims, filter_dims);

  auto filter_size = filter_dims.TotalSize();
  auto flops = filter_size * (input_batches * input_height * input_width);
  ::tensorflow::testing::ItemsProcessed(flops * iters);
}

// Macro arguments names: --------------------------------------------------- //
//   NT: num threads
//    N: batch size
//    H: height
//    W: width
//    C: channels
//   FC: filter count
//   FH: filter height
//   FW: filter width

#define BM_SPATIAL_NAME(prefix, NT, N, H, W, C, FC, FH, FW) \
  BM_##prefix##_CPU_##NT##T_in_##N##_##H##_##W##_##C##_f_##FC##_##FH##_##FW

#define BM_SpatialConvolution(NT, N, H, W, C, FC, FH, FW, LABEL)          \
  static void BM_SPATIAL_NAME(SpatialConvolution, NT, N, H, W, C, FC, FH, \
                              FW)(int iters) {                            \
    ::tensorflow::testing::SetLabel(LABEL);                               \
    SpatialConvolution(iters, NT, N, H, W, C, FC, FH, FW);                \
  }                                                                       \
  BENCHMARK(BM_SPATIAL_NAME(SpatialConvolution, NT, N, H, W, C, FC, FH, FW))

#define BM_SpatialConvolutionBwdInput(NT, N, H, W, C, FC, FH, FW, LABEL)      \
  static void BM_SPATIAL_NAME(SpatialConvolutionBwdInput, NT, N, H, W, C, FC, \
                              FH, FW)(int iters) {                            \
    ::tensorflow::testing::SetLabel(LABEL);                                   \
    SpatialConvolutionBackwardInput(iters, NT, N, H, W, C, FC, FH, FW);       \
  }                                                                           \
  BENCHMARK(                                                                  \
      BM_SPATIAL_NAME(SpatialConvolutionBwdInput, NT, N, H, W, C, FC, FH, FW))

#define BM_SpatialConvolutionBwdKernel(NT, N, H, W, C, FC, FH, FW, LABEL)      \
  static void BM_SPATIAL_NAME(SpatialConvolutionBwdKernel, NT, N, H, W, C, FC, \
                              FH, FW)(int iters) {                             \
    ::tensorflow::testing::SetLabel(LABEL);                                    \
    SpatialConvolutionBackwardKernel(iters, NT, N, H, W, C, FC, FH, FW);       \
  }                                                                            \
  BENCHMARK(BM_SPATIAL_NAME(SpatialConvolutionBwdKernel, NT, N, H, W, C, FC,   \
                            FH, FW))

#define BM_SpatialConvolutions(N, H, W, C, FC, FH, FW, LABEL) \
  BM_SpatialConvolution(2, N, H, W, C, FC, FH, FW, LABEL);    \
  BM_SpatialConvolution(4, N, H, W, C, FC, FH, FW, LABEL);    \
  BM_SpatialConvolution(8, N, H, W, C, FC, FH, FW, LABEL);    \
  BM_SpatialConvolution(16, N, H, W, C, FC, FH, FW, LABEL);

#define BM_SpatialConvolutionsBwdInput(N, H, W, C, FC, FH, FW, LABEL) \
  BM_SpatialConvolutionBwdInput(2, N, H, W, C, FC, FH, FW, LABEL);    \
  BM_SpatialConvolutionBwdInput(4, N, H, W, C, FC, FH, FW, LABEL);    \
  BM_SpatialConvolutionBwdInput(8, N, H, W, C, FC, FH, FW, LABEL);    \
  BM_SpatialConvolutionBwdInput(16, N, H, W, C, FC, FH, FW, LABEL);

#define BM_SpatialConvolutionsBwdKernel(N, H, W, C, FC, FH, FW, LABEL) \
  BM_SpatialConvolutionBwdKernel(2, N, H, W, C, FC, FH, FW, LABEL);    \
  BM_SpatialConvolutionBwdKernel(4, N, H, W, C, FC, FH, FW, LABEL);    \
  BM_SpatialConvolutionBwdKernel(8, N, H, W, C, FC, FH, FW, LABEL);    \
  BM_SpatialConvolutionBwdKernel(16, N, H, W, C, FC, FH, FW, LABEL);

// ImageNet Forward Convolutions -------------------------------------------- //

BM_SpatialConvolutions(32,          // batch size
                       56, 56, 64,  // input: height, width, depth
                       192, 3, 3,   // filter: count, height, width
                       "conv2_00");

BM_SpatialConvolutions(32, 28, 28, 96, 128, 3, 3, "conv3a_00_3x3");
BM_SpatialConvolutions(32, 28, 28, 16, 32, 5, 5, "conv3a_00_5x5");
BM_SpatialConvolutions(32, 28, 28, 128, 192, 3, 3, "conv3_00_3x3");
BM_SpatialConvolutions(32, 28, 28, 32, 96, 5, 5, "conv3_00_5x5");
BM_SpatialConvolutions(32, 14, 14, 96, 204, 3, 3, "conv4a_00_3x3");
BM_SpatialConvolutions(32, 14, 14, 16, 48, 5, 5, "conv4a_00_5x5");
BM_SpatialConvolutions(32, 14, 14, 112, 224, 3, 3, "conv4b_00_3x3");
BM_SpatialConvolutions(32, 14, 14, 24, 64, 5, 5,
                       "conv4b_00_5x5 / conv4c_00_5x5");
BM_SpatialConvolutions(32, 14, 14, 128, 256, 3, 3, "conv4c_00_3x3");
BM_SpatialConvolutions(32, 14, 14, 144, 288, 3, 3, "conv4d_00_3x3");
BM_SpatialConvolutions(32, 14, 14, 32, 64, 5, 5, "conv4d_00_5x5");
BM_SpatialConvolutions(32, 14, 14, 160, 320, 3, 3, "conv4_00_3x3");
BM_SpatialConvolutions(32, 14, 14, 32, 128, 5, 5, "conv4_00_5x5");
BM_SpatialConvolutions(32, 7, 7, 160, 320, 3, 3, "conv5a_00_3x3");
BM_SpatialConvolutions(32, 7, 7, 48, 128, 5, 5, "conv5a_00_5x5 / conv5_00_5x5");
BM_SpatialConvolutions(32, 7, 7, 192, 384, 3, 3, "conv5_00_3x3");

// Benchmarks from https://github.com/soumith/convnet-benchmarks
BM_SpatialConvolutions(128, 128, 128, 3, 96, 11, 11, "convnet-layer1");
BM_SpatialConvolutions(128, 64, 64, 64, 128, 9, 9, "convnet-layer2");
BM_SpatialConvolutions(128, 32, 32, 128, 128, 9, 9, "convnet-layer3");
BM_SpatialConvolutions(128, 16, 16, 128, 128, 7, 7, "convnet-layer4");
BM_SpatialConvolutions(128, 13, 13, 384, 384, 3, 3, "convnet-layer5");

// ImageNet BackwardInput Convolutions -------------------------------------- //

BM_SpatialConvolutionsBwdInput(32, 56, 56, 64, 192, 3, 3, "conv2_00");
BM_SpatialConvolutionsBwdInput(32, 28, 28, 96, 128, 3, 3, "conv3a_00_3x3");
BM_SpatialConvolutionsBwdInput(32, 28, 28, 16, 32, 5, 5, "conv3a_00_5x5");
BM_SpatialConvolutionsBwdInput(32, 28, 28, 128, 192, 3, 3, "conv3_00_3x3");
BM_SpatialConvolutionsBwdInput(32, 28, 28, 32, 96, 5, 5, "conv3_00_5x5");
BM_SpatialConvolutionsBwdInput(32, 14, 14, 96, 204, 3, 3, "conv4a_00_3x3");
BM_SpatialConvolutionsBwdInput(32, 14, 14, 16, 48, 5, 5, "conv4a_00_5x5");
BM_SpatialConvolutionsBwdInput(32, 14, 14, 112, 224, 3, 3, "conv4b_00_3x3");
BM_SpatialConvolutionsBwdInput(32, 14, 14, 24, 64, 5, 5,
                               "conv4b_00_5x5 / conv4c_00_5x5");
BM_SpatialConvolutionsBwdInput(32, 14, 14, 128, 256, 3, 3, "conv4c_00_3x3");
BM_SpatialConvolutionsBwdInput(32, 14, 14, 144, 288, 3, 3, "conv4d_00_3x3");
BM_SpatialConvolutionsBwdInput(32, 14, 14, 32, 64, 5, 5, "conv4d_00_5x5");
BM_SpatialConvolutionsBwdInput(32, 14, 14, 160, 320, 3, 3, "conv4_00_3x3");
BM_SpatialConvolutionsBwdInput(32, 14, 14, 32, 128, 5, 5, "conv4_00_5x5");
BM_SpatialConvolutionsBwdInput(32, 7, 7, 160, 320, 3, 3, "conv5a_00_3x3");
BM_SpatialConvolutionsBwdInput(32, 7, 7, 48, 128, 5, 5,
                               "conv5a_00_5x5 / conv5_00_5x5");
BM_SpatialConvolutionsBwdInput(32, 7, 7, 192, 384, 3, 3, "conv5_00_3x3");

// ImageNet BackwardKernel Convolutions ------------------------------------- //

BM_SpatialConvolutionsBwdKernel(32, 56, 56, 64, 192, 3, 3, "conv2_00");
BM_SpatialConvolutionsBwdKernel(32, 28, 28, 96, 128, 3, 3, "conv3a_00_3x3");
BM_SpatialConvolutionsBwdKernel(32, 28, 28, 16, 32, 5, 5, "conv3a_00_5x5");
BM_SpatialConvolutionsBwdKernel(32, 28, 28, 128, 192, 3, 3, "conv3_00_3x3");
BM_SpatialConvolutionsBwdKernel(32, 28, 28, 32, 96, 5, 5, "conv3_00_5x5");
BM_SpatialConvolutionsBwdKernel(32, 14, 14, 96, 204, 3, 3, "conv4a_00_3x3");
BM_SpatialConvolutionsBwdKernel(32, 14, 14, 16, 48, 5, 5, "conv4a_00_5x5");
BM_SpatialConvolutionsBwdKernel(32, 14, 14, 112, 224, 3, 3, "conv4b_00_3x3");
BM_SpatialConvolutionsBwdKernel(32, 14, 14, 24, 64, 5, 5,
                                "conv4b_00_5x5 / conv4c_00_5x5");
BM_SpatialConvolutionsBwdKernel(32, 14, 14, 128, 256, 3, 3, "conv4c_00_3x3");
BM_SpatialConvolutionsBwdKernel(32, 14, 14, 144, 288, 3, 3, "conv4d_00_3x3");
BM_SpatialConvolutionsBwdKernel(32, 14, 14, 32, 64, 5, 5, "conv4d_00_5x5");
BM_SpatialConvolutionsBwdKernel(32, 14, 14, 160, 320, 3, 3, "conv4_00_3x3");
BM_SpatialConvolutionsBwdKernel(32, 14, 14, 32, 128, 5, 5, "conv4_00_5x5");
BM_SpatialConvolutionsBwdKernel(32, 7, 7, 160, 320, 3, 3, "conv5a_00_3x3");
BM_SpatialConvolutionsBwdKernel(32, 7, 7, 48, 128, 5, 5,
                                "conv5a_00_5x5 / conv5_00_5x5");
BM_SpatialConvolutionsBwdKernel(32, 7, 7, 192, 384, 3, 3, "conv5_00_3x3");

// -------------------------------------------------------------------------- //
// Cuboid Convolutions                                                        //
// -------------------------------------------------------------------------- //

void CuboidConvolution(int iters, int num_threads,
                       /* Input dimensions: */
                       int input_batches, int input_height, int input_width,
                       int input_planes, int input_depth,
                       /* Filter (kernel) dimensions: */
                       int filter_count, int filter_height, int filter_width,
                       int filter_planes) {
  ::tensorflow::testing::StopTiming();

  CREATE_THREAD_POOL(num_threads);

  using Benchmark =
      CuboidConvolutionBenchmarksSuite<float, Eigen::ThreadPoolDevice>;
  auto benchmark = Benchmark(iters, device);

  typename Benchmark::Dimensions input_dims(
      input_batches, input_height, input_width, input_planes, input_depth);
  typename Benchmark::Dimensions filter_dims(
      filter_height, filter_width, filter_planes, input_depth, filter_count);

  benchmark.CuboidConvolution(input_dims, filter_dims);

  auto output_size = input_dims.TotalSize();
  auto flops = output_size *
               (input_depth * filter_height * filter_width * filter_planes);
  ::tensorflow::testing::ItemsProcessed(flops * iters);
}

void CuboidConvolutionBackwardInput(int iters, int num_threads,
                                    /* Input dimensions: */
                                    int input_batches, int input_height,
                                    int input_width, int input_planes,
                                    int input_depth,
                                    /* Filter (kernel) dimensions: */
                                    int filter_count, int filter_height,
                                    int filter_width, int filter_planes) {
  ::tensorflow::testing::StopTiming();

  CREATE_THREAD_POOL(num_threads);

  using Benchmark =
      CuboidConvolutionBenchmarksSuite<float, Eigen::ThreadPoolDevice>;
  auto benchmark = Benchmark(iters, device);

  typename Benchmark::Dimensions input_dims(
      input_batches, input_height, input_width, input_planes, input_depth);
  typename Benchmark::Dimensions filter_dims(
      filter_height, filter_width, filter_planes, input_depth, filter_count);

  benchmark.CuboidConvolutionBackwardInput(input_dims, filter_dims);

  auto output_size = input_dims.TotalSize();
  auto flops = output_size *
               (input_depth * filter_height * filter_width * filter_planes);
  ::tensorflow::testing::ItemsProcessed(flops * iters);
}

void CuboidConvolutionBackwardKernel(int iters, int num_threads,
                                     /* Input dimensions: */
                                     int input_batches, int input_height,
                                     int input_width, int input_planes,
                                     int input_depth,
                                     /* Filter (kernel) dimensions: */
                                     int filter_count, int filter_height,
                                     int filter_width, int filter_planes) {
  ::tensorflow::testing::StopTiming();

  CREATE_THREAD_POOL(num_threads);

  using Benchmark =
      CuboidConvolutionBenchmarksSuite<float, Eigen::ThreadPoolDevice>;
  auto benchmark = Benchmark(iters, device);

  typename Benchmark::Dimensions input_dims(
      input_batches, input_height, input_width, input_planes, input_depth);
  typename Benchmark::Dimensions filter_dims(
      filter_height, filter_width, filter_planes, input_depth, filter_count);

  benchmark.CuboidConvolutionBackwardKernel(input_dims, filter_dims);

  auto filter_size = filter_dims.TotalSize();
  auto flops =
      filter_size * (input_batches * input_height * input_width * input_planes);
  ::tensorflow::testing::ItemsProcessed(flops * iters);
}

// Macro arguments names: --------------------------------------------------- //
//   NT: num threads
//    N: batch size
//    H: height
//    W: width
//    P: panes
//    C: channels
//   FC: filter count
//   FH: filter height
//   FW: filter width
//   FP: filter panes

#define BM_CONCAT(a, b) a##b

#define BM_CUBOID_NAME(p, NT, N, H, W, P, C, FC, FH, FW, FP)     \
  BM_CONCAT(BM_##p##_CPU_##NT##T_in_##N##_##H##_##W##_##P##_##C, \
            _f_##FC##_##FH##_##FW##_##FP)

#define BM_CuboidConvolution(NT, N, H, W, P, C, FC, FH, FW, FP, LABEL)         \
  static void BM_CUBOID_NAME(CuboidConvolution, NT, N, H, W, P, C, FC, FH, FW, \
                             FP)(int iters) {                                  \
    ::tensorflow::testing::SetLabel(LABEL);                                    \
    CuboidConvolution(iters, NT, N, H, W, P, C, FC, FH, FW, FP);               \
  }                                                                            \
  BENCHMARK(                                                                   \
      BM_CUBOID_NAME(CuboidConvolution, NT, N, H, W, P, C, FC, FH, FW, FP))

#define BM_CuboidConvolutionBwdInput(NT, N, H, W, P, C, FC, FH, FW, FP, LABEL) \
  static void BM_CUBOID_NAME(CuboidConvolutionBwdInput, NT, N, H, W, P, C, FC, \
                             FH, FW, FP)(int iters) {                          \
    ::tensorflow::testing::SetLabel(LABEL);                                    \
    CuboidConvolutionBackwardInput(iters, NT, N, H, W, P, C, FC, FH, FW, FP);  \
  }                                                                            \
  BENCHMARK(BM_CUBOID_NAME(CuboidConvolutionBwdInput, NT, N, H, W, P, C, FC,   \
                           FH, FW, FP))

#define BM_CuboidConvolutionBwdKernel(NT, N, H, W, P, C, FC, FH, FW, FP,       \
                                      LABEL)                                   \
  static void BM_CUBOID_NAME(CuboidConvolutionBwdKernel, NT, N, H, W, P, C,    \
                             FC, FH, FW, FP)(int iters) {                      \
    ::tensorflow::testing::SetLabel(LABEL);                                    \
    CuboidConvolutionBackwardKernel(iters, NT, N, H, W, P, C, FC, FH, FW, FP); \
  }                                                                            \
  BENCHMARK(BM_CUBOID_NAME(CuboidConvolutionBwdKernel, NT, N, H, W, P, C, FC,  \
                           FH, FW, FP))

#define BM_CuboidConvolutions(N, H, W, P, C, FC, FH, FW, FP, LABEL) \
  BM_CuboidConvolution(2, N, H, W, P, C, FC, FH, FW, FP, LABEL);    \
  BM_CuboidConvolution(4, N, H, W, P, C, FC, FH, FW, FP, LABEL);    \
  BM_CuboidConvolution(8, N, H, W, P, C, FC, FH, FW, FP, LABEL);    \
  BM_CuboidConvolution(16, N, H, W, P, C, FC, FH, FW, FP, LABEL);

#define BM_CuboidConvolutionsBwdInput(N, H, W, P, C, FC, FH, FW, FP, LABEL) \
  BM_CuboidConvolutionBwdInput(2, N, H, W, P, C, FC, FH, FW, FP, LABEL);    \
  BM_CuboidConvolutionBwdInput(4, N, H, W, P, C, FC, FH, FW, FP, LABEL);    \
  BM_CuboidConvolutionBwdInput(8, N, H, W, P, C, FC, FH, FW, FP, LABEL);    \
  BM_CuboidConvolutionBwdInput(16, N, H, W, P, C, FC, FH, FW, FP, LABEL);

#define BM_CuboidConvolutionsBwdKernel(N, H, W, P, C, FC, FH, FW, FP, LABEL) \
  BM_CuboidConvolutionBwdKernel(2, N, H, W, P, C, FC, FH, FW, FP, LABEL);    \
  BM_CuboidConvolutionBwdKernel(4, N, H, W, P, C, FC, FH, FW, FP, LABEL);    \
  BM_CuboidConvolutionBwdKernel(8, N, H, W, P, C, FC, FH, FW, FP, LABEL);    \
  BM_CuboidConvolutionBwdKernel(16, N, H, W, P, C, FC, FH, FW, FP, LABEL);

// Random Cuboid Convolutions ----------------------------------------------- //
// TODO(ezhulenev): find representative dims for cuboid convolutions (find
// models using Conv3D ops).

BM_CuboidConvolutions(8,              // batch size
                      25, 25, 25, 4,  // input: height, width, panes, depth
                      16, 5, 5, 5,    // filter: count, height, width, panes
                      "conv3d_depth4");
BM_CuboidConvolutions(8, 25, 25, 25, 8, 16, 5, 5, 5, "conv3d_depth8");
BM_CuboidConvolutions(2, 9, 31, 31, 64, 64, 5, 5, 5, "b2_conv3d_1");
BM_CuboidConvolutions(2, 5, 27, 27, 64, 64, 5, 5, 5, "b2_conv3d_2");

BM_CuboidConvolutionsBwdInput(8, 25, 25, 25, 4, 16, 5, 5, 5, "conv3d_depth4");
BM_CuboidConvolutionsBwdInput(8, 25, 25, 25, 8, 16, 5, 5, 5, "conv3d_depth8");
BM_CuboidConvolutionsBwdInput(2, 9, 31, 31, 64, 64, 5, 5, 5, "b2_conv3d_1");
BM_CuboidConvolutionsBwdInput(2, 5, 27, 27, 64, 64, 5, 5, 5, "b2_conv3d_2");

BM_CuboidConvolutionsBwdKernel(8, 25, 25, 25, 4, 16, 5, 5, 5, "conv3d_depth4");
BM_CuboidConvolutionsBwdKernel(8, 25, 25, 25, 8, 16, 5, 5, 5, "conv3d_depth8");
BM_CuboidConvolutionsBwdKernel(2, 9, 31, 31, 64, 64, 5, 5, 5, "b2_conv3d_1");
BM_CuboidConvolutionsBwdKernel(2, 5, 27, 27, 64, 64, 5, 5, 5, "b2_conv3d_2");