Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / common / memory_desc_wrapper.cpp
1 /*******************************************************************************
2 * Copyright 2016-2018 Intel Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16
17 #include <assert.h>
18 #include "mkldnn_types.h"
19
20 #include "c_types_map.hpp"
21 #include "memory_desc_wrapper.hpp"
22 #include "memory_pd.hpp"
23 #include "type_helpers.hpp"
24 #include "utils.hpp"
25
26 namespace mkldnn {
27 namespace impl {
28
29 memory_desc_wrapper::memory_desc_wrapper(const memory_pd_t *m_pd)
30     : _md(m_pd == nullptr ? nullptr : m_pd->desc()) {}
31
32 namespace {
33 using namespace mkldnn::impl::utils;
34 using namespace mkldnn::impl::status;
35 using namespace mkldnn::impl::memory_format;
36
37 status_t fill_x(memory_desc_t &md) {
38     const int ndims = md.ndims;
39     if (ndims != 1) return invalid_arguments;
40     blocking_desc_t &blk = md.layout_desc.blocking;
41     array_set(blk.block_dims, 1, ndims);
42     array_set(blk.strides[1], 1, ndims);
43     blk.strides[0][0] = 1;
44     array_copy(blk.padding_dims, md.dims, ndims);
45     array_set(blk.offset_padding_to_data, 0, ndims);
46     blk.offset_padding = 0;
47     return success;
48 }
49
50 /* TODO: improve me maybe... and put this to utils */
51 inline void set_default_strides(strides_t strides, const dims_t dims,
52         int ndims, const int *perm = NULL) {
53     int id_perm[TENSOR_MAX_DIMS] = {0};
54     for (int i = 0; i < ndims; ++i)
55         id_perm[i] = i;
56     if (perm == NULL)
57         perm = id_perm;
58
59     strides[perm[ndims - 1]] = 1;
60     for (int d = 1; d < ndims; ++d) {
61         const int prev_idx = perm[ndims - d];
62         const int curr_idx = perm[ndims - 1 - d];
63
64         strides[curr_idx] = dims[curr_idx] == 0
65             ? 1
66             : strides[prev_idx] * nstl::max((ptrdiff_t)1, dims[prev_idx]);
67     }
68 }
69
70 status_t fill_nonblocked(memory_desc_t &md, const int perm[]) {
71     const int ndims = md.ndims;
72     blocking_desc_t &blk = md.layout_desc.blocking;
73     array_set(blk.block_dims, 1, ndims);
74     array_set(blk.strides[1], 1, ndims);
75
76     if (md.format == mkldnn_nhwc && md.data_type == mkldnn_bin) {
77         dims_t padding_dims;
78
79         const dims_t block_dims = {1, 8, 1, 1};
80         for (int d = 0; d < ndims; ++d) {
81             padding_dims[d] = rnd_up(md.dims[d], block_dims[d]);
82         }
83
84         set_default_strides(blk.strides[0], padding_dims, ndims, perm);
85         array_copy(blk.padding_dims, padding_dims, ndims);
86
87     } else {
88         set_default_strides(blk.strides[0], md.dims, ndims, perm);
89         array_copy(blk.padding_dims, md.dims, ndims);
90     }
91
92     array_set(blk.offset_padding_to_data, 0, ndims);
93     blk.offset_padding = 0;
94
95     return success;
96 }
97
98 status_t fill_contiguous_blocked(memory_desc_t &md, const dims_t block_dims,
99         const int perm[]) {
100     const int ndims = md.ndims;
101
102     blocking_desc_t &blk = md.layout_desc.blocking;
103     array_copy(blk.block_dims, block_dims, ndims);
104
105     dim_t unrolled_dims[2*TENSOR_MAX_DIMS];
106     stride_t unrolled_strides[2*TENSOR_MAX_DIMS];
107     dims_t padding_dims;
108
109     for (int d = 0; d < ndims; ++d) {
110         unrolled_dims[d] = div_up(md.dims[d], block_dims[d]);
111         unrolled_dims[ndims + d] = block_dims[d];
112         padding_dims[d] = rnd_up(md.dims[d], block_dims[d]);
113     }
114
115     set_default_strides(unrolled_strides, unrolled_dims, 2*ndims, perm);
116     array_copy(blk.strides[0], &unrolled_strides[0], ndims);
117     array_copy(blk.strides[1], &unrolled_strides[ndims], ndims);
118     array_copy(blk.padding_dims, padding_dims, ndims);
119     array_set(blk.offset_padding_to_data, 0, ndims);
120     blk.offset_padding = 0;
121     return success;
122 }
123
124 status_t fill_nc(memory_desc_t &md) {
125     if (md.ndims != 2) return invalid_arguments;
126
127     const int perm[2] = {0, 1};
128     return fill_nonblocked(md, perm);
129 }
130
131 status_t fill_ncw(memory_desc_t &md) {
132     if (md.ndims != 3) return invalid_arguments;
133
134     const int perm[3] = {0, 1, 2};
135     return fill_nonblocked(md, perm);
136 }
137
138 status_t fill_nwc(memory_desc_t &md) {
139     if (md.ndims != 3) return invalid_arguments;
140
141     const int perm[3] = {0, 2, 1};
142     return fill_nonblocked(md, perm);
143 }
144
145 status_t fill_nCw4c(memory_desc_t &md) {
146     if (md.ndims != 3) return invalid_arguments;
147
148     const dims_t block_dims = { 1, 4, 1 };
149     const int perm[] = {
150         0, 1, 2,
151         3, 4, 5 };
152     return fill_contiguous_blocked(md, block_dims, perm);
153 }
154
155
156 status_t fill_nCw8c(memory_desc_t &md) {
157     if (md.ndims != 3) return invalid_arguments;
158
159     const dims_t block_dims = {1, 8, 1, 1};
160     const int perm[] = {
161         0, 1, 2,
162         3, 4, 5};
163     return fill_contiguous_blocked(md, block_dims, perm);
164 }
165
166 status_t fill_nCw16c(memory_desc_t &md) {
167     if (md.ndims != 3) return invalid_arguments;
168
169     const dims_t block_dims = {1, 16, 1};
170     const int perm[] = {
171         0, 1, 2,
172         3, 4, 5};
173     return fill_contiguous_blocked(md, block_dims, perm);
174 }
175
176 status_t fill_nchw(memory_desc_t &md) {
177     if (md.ndims != 4) return invalid_arguments;
178
179     const int perm[4] = {0, 1, 2, 3};
180     return fill_nonblocked(md, perm);
181 }
182
183 status_t fill_ncdhw(memory_desc_t &md) {
184     if (md.ndims != 5) return invalid_arguments;
185
186     const int perm[5] = {0, 1, 2, 3, 4};
187     return fill_nonblocked(md, perm);
188 }
189
190 status_t fill_oidhw(memory_desc_t &md) {
191     if (md.ndims != 5) return invalid_arguments;
192
193     const int perm[5] = {0, 1, 2, 3, 4};
194     return fill_nonblocked(md, perm);
195 }
196
197 status_t fill_goidhw(memory_desc_t &md) {
198     if (md.ndims != 6) return invalid_arguments;
199
200     const int perm[6] = {0, 1, 2, 3, 4, 5};
201     return fill_nonblocked(md, perm);
202 }
203
204 status_t fill_nhwc(memory_desc_t &md) {
205     if (md.ndims != 4) return invalid_arguments;
206
207     const int perm[4] = {0, 2, 3, 1};
208     return fill_nonblocked(md, perm);
209 }
210
211 status_t fill_ndhwc(memory_desc_t &md) {
212     if (md.ndims != 5) return invalid_arguments;
213
214     const int perm[5] = {0, 2, 3, 4, 1};
215     return fill_nonblocked(md, perm);
216 }
217
218 status_t fill_chwn(memory_desc_t &md) {
219     if (md.ndims != 4) return invalid_arguments;
220
221     const int perm[4] = {1, 2, 3, 0};
222     return fill_nonblocked(md, perm);
223 }
224
225 status_t fill_nChw4c(memory_desc_t &md) {
226     if (md.ndims != 4) return invalid_arguments;
227
228     const dims_t block_dims = { 1, 4, 1, 1 };
229     const int perm[] = {
230         0, 1, 2, 3,
231         4, 5, 6, 7 };
232     return fill_contiguous_blocked(md, block_dims, perm);
233 }
234
235 status_t fill_nChw8c(memory_desc_t &md) {
236     if (md.ndims != 4) return invalid_arguments;
237
238     const dims_t block_dims = {1, 8, 1, 1};
239     const int perm[] = {
240         0, 1, 2, 3,
241         4, 5, 6, 7};
242     return fill_contiguous_blocked(md, block_dims, perm);
243 }
244
245 status_t fill_nChw16c(memory_desc_t &md) {
246     if (md.ndims != 4) return invalid_arguments;
247
248     const dims_t block_dims = {1, 16, 1, 1};
249     const int perm[] = {
250         0, 1, 2, 3,
251         4, 5, 6, 7};
252     return fill_contiguous_blocked(md, block_dims, perm);
253 }
254
255 status_t fill_nCdhw16c(memory_desc_t &md) {
256     if (md.ndims != 5) return invalid_arguments;
257
258     const dims_t block_dims = {1, 16, 1, 1, 1};
259     const int perm[] = {
260         0, 1, 2, 3, 4,
261         5, 6, 7, 8, 9};
262     return fill_contiguous_blocked(md, block_dims, perm);
263 }
264
265 status_t fill_nCdhw4c(memory_desc_t &md) {
266     if (md.ndims != 5) return invalid_arguments;
267
268     const dims_t block_dims = { 1, 4, 1, 1, 1 };
269     const int perm[] = {
270         0, 1, 2, 3, 4,
271         5, 6, 7, 8, 9 };
272     return fill_contiguous_blocked(md, block_dims, perm);
273 }
274
275 status_t fill_nCdhw8c(memory_desc_t &md) {
276     if (md.ndims != 5) return invalid_arguments;
277
278     const dims_t block_dims = {1, 8, 1, 1, 1};
279     const int perm[] = {
280         0, 1, 2, 3, 4,
281         5, 6, 7, 8, 9};
282     return fill_contiguous_blocked(md, block_dims, perm);
283 }
284
285 status_t fill_oi(memory_desc_t &md) {
286     if (md.ndims != 2) return invalid_arguments;
287
288     const int perm[2] = {0, 1};
289     return fill_nonblocked(md, perm);
290 }
291
292 status_t fill_io(memory_desc_t &md) {
293     if (md.ndims != 2) return invalid_arguments;
294
295     const int perm[2] = {1, 0};
296     return fill_nonblocked(md, perm);
297 }
298
299 status_t fill_oiw(memory_desc_t &md) {
300     if (md.ndims != 3) return invalid_arguments;
301
302     const int perm[3] = {0, 1, 2};
303     return fill_nonblocked(md, perm);
304 }
305
306 status_t fill_wio(memory_desc_t &md) {
307     if (md.ndims != 3) return invalid_arguments;
308
309     const int perm[3] = {2, 1, 0};
310     return fill_nonblocked(md, perm);
311 }
312
313 status_t fill_Owi4o(memory_desc_t &md) {
314     if (md.ndims != 3) return invalid_arguments;
315
316     const dims_t block_dims = { 4, 1, 1 };
317     const int perm[] = {
318         0, 2, 1,
319         3, 4, 5 };
320     return fill_contiguous_blocked(md, block_dims, perm);
321 }
322
323 status_t fill_Owi8o(memory_desc_t &md) {
324     if (md.ndims != 3) return invalid_arguments;
325
326     const dims_t block_dims = {8, 1, 1};
327     const int perm[] = {
328         0, 2, 1,
329         3, 4, 5};
330     return fill_contiguous_blocked(md, block_dims, perm);
331 }
332
333 status_t fill_OIw8o8i(memory_desc_t &md) {
334     if (md.ndims != 3) return invalid_arguments;
335
336     const dims_t block_dims = {8, 8, 1};
337     const int perm[] = {
338         0, 1, 2,
339         3, 4, 5};
340     return fill_contiguous_blocked(md, block_dims, perm);
341 }
342
343 status_t fill_OIw4i4o(memory_desc_t &md) {
344     if (md.ndims != 3) return invalid_arguments;
345
346     const dims_t block_dims = { 4, 4, 1 };
347     const int perm[] = {
348         0, 1, 2,
349         4, 3, 5 };
350     return fill_contiguous_blocked(md, block_dims, perm);
351 }
352
353 status_t fill_OIw8i8o(memory_desc_t &md) {
354     if (md.ndims != 3) return invalid_arguments;
355
356     const dims_t block_dims = {8, 8, 1};
357     const int perm[] = {
358         0, 1, 2,
359         4, 3, 5};
360     return fill_contiguous_blocked(md, block_dims, perm);
361 }
362
363 status_t fill_OIw16i16o(memory_desc_t &md) {
364     if (md.ndims != 3) return invalid_arguments;
365
366     const dims_t block_dims = {16, 16, 1};
367     const int perm[] = {
368         0, 1, 2,
369         4, 3, 5};
370     return fill_contiguous_blocked(md, block_dims, perm);
371 }
372
373 status_t fill_OIw16o16i(memory_desc_t &md) {
374     if (md.ndims != 3) return invalid_arguments;
375
376     const dims_t block_dims = {16, 16, 1};
377     const int perm[] = {
378         0, 1, 2,
379         3, 4, 5};
380     return fill_contiguous_blocked(md, block_dims, perm);
381 }
382
383 status_t fill_Oiw4o(memory_desc_t &md) {
384     if (md.ndims != 3) return invalid_arguments;
385
386     const dims_t block_dims = {4, 1, 1};
387     const int perm[] = {
388         0, 1, 2,
389         3, 4, 5};
390     return fill_contiguous_blocked(md, block_dims, perm);
391 }
392
393 status_t fill_Oiw16o(memory_desc_t &md) {
394     if (md.ndims != 3) return invalid_arguments;
395
396     const dims_t block_dims = { 16, 1, 1 };
397     const int perm[] = {
398         0, 1, 2,
399         3, 4, 5 };
400     return fill_contiguous_blocked(md, block_dims, perm);
401 }
402
403 status_t fill_Owi16o(memory_desc_t &md) {
404     if (md.ndims != 3) return invalid_arguments;
405
406     const dims_t block_dims = {16, 1, 1};
407     const int perm[] = {
408         0, 2, 1,
409         3, 4, 5};
410     return fill_contiguous_blocked(md, block_dims, perm);
411 }
412
413 status_t fill_OIw8i16o2i(memory_desc_t &md) {
414     if (md.ndims != 3) return invalid_arguments;
415
416     const dims_t block_dims = {16, 16, 1};
417     const int perm[] = {
418         0, 1, 2,
419         4, 3, 5};
420     return fill_contiguous_blocked(md, block_dims, perm);
421 }
422
423 status_t fill_IOw16o16i(memory_desc_t &md) {
424     if (md.ndims != 3) return invalid_arguments;
425
426     const dims_t block_dims = {16, 16, 1};
427     const int perm[] = {
428         1, 0, 2,
429         3, 4, 5};
430     return fill_contiguous_blocked(md, block_dims, perm);
431 }
432
433 status_t fill_OIw8o16i2o(memory_desc_t &md) {
434     if (md.ndims != 3) return invalid_arguments;
435
436     const dims_t block_dims = {16, 16, 1};
437     const int perm[] = {
438         0, 1, 2,
439         3, 4, 5};
440     return fill_contiguous_blocked(md, block_dims, perm);
441 }
442
443 status_t fill_oihw(memory_desc_t &md) {
444     if (md.ndims != 4) return invalid_arguments;
445
446     const int perm[4] = {0, 1, 2, 3};
447     return fill_nonblocked(md, perm);
448 }
449
450 status_t fill_ihwo(memory_desc_t &md) {
451     if (md.ndims != 4) return invalid_arguments;
452
453     const int perm[4] = {1, 2, 3, 0};
454     return fill_nonblocked(md, perm);
455 }
456
457 status_t fill_hwio(memory_desc_t &md) {
458     if (md.ndims != 4) return invalid_arguments;
459
460     const int perm[4] = {2, 3, 1, 0};
461     return fill_nonblocked(md, perm);
462 }
463
464 status_t fill_iohw(memory_desc_t &md) {
465     if (md.ndims != 4) return invalid_arguments;
466
467     const int perm[4] = {1, 0, 2, 3};
468     return fill_nonblocked(md, perm);
469 }
470
471 status_t fill_dhwio(memory_desc_t &md) {
472     if (md.ndims != 5) return invalid_arguments;
473
474     const int perm[5] = {2, 3, 4, 1, 0};
475     return fill_nonblocked(md, perm);
476 }
477
478 status_t fill_OIhw4i4o(memory_desc_t &md) {
479     if (md.ndims != 4) return invalid_arguments;
480
481     const dims_t block_dims = { 4, 4, 1, 1 };
482     const int perm[] = {
483         0, 1, 2, 3,
484         5, 4, 6, 7 };
485     return fill_contiguous_blocked(md, block_dims, perm);
486 }
487
488 status_t fill_OIhw8i8o(memory_desc_t &md) {
489     if (md.ndims != 4) return invalid_arguments;
490
491     const dims_t block_dims = {8, 8, 1, 1};
492     const int perm[] = {
493         0, 1, 2, 3,
494         5, 4, 6, 7};
495     return fill_contiguous_blocked(md, block_dims, perm);
496 }
497
498 status_t fill_OIhw16i16o(memory_desc_t &md) {
499     if (md.ndims != 4) return invalid_arguments;
500
501     const dims_t block_dims = {16, 16, 1, 1};
502     const int perm[] = {
503         0, 1, 2, 3,
504         5, 4, 6, 7};
505     return fill_contiguous_blocked(md, block_dims, perm);
506 }
507
508 status_t fill_OIdhw16i16o(memory_desc_t &md) {
509     if (md.ndims != 5) return invalid_arguments;
510
511     const dims_t block_dims = {16, 16, 1, 1, 1};
512     const int perm[] = {
513         0, 1, 2, 3, 4,
514         6, 5, 7, 8, 9};
515     return fill_contiguous_blocked(md, block_dims, perm);
516 }
517
518 status_t fill_OIdhw4i4o(memory_desc_t &md) {
519     if (md.ndims != 5) return invalid_arguments;
520
521     const dims_t block_dims = { 4, 4, 1, 1, 1 };
522     const int perm[] = {
523         0, 1, 2, 3, 4,
524         6, 5, 7, 8, 9 };
525     return fill_contiguous_blocked(md, block_dims, perm);
526 }
527
528 status_t fill_OIdhw8i8o(memory_desc_t &md) {
529     if (md.ndims != 5) return invalid_arguments;
530
531     const dims_t block_dims = {8, 8, 1, 1, 1};
532     const int perm[] = {
533         0, 1, 2, 3, 4,
534         6, 5, 7, 8, 9};
535     return fill_contiguous_blocked(md, block_dims, perm);
536 }
537
538 status_t fill_OIhw4i16o4i(memory_desc_t &md) {
539     if (md.ndims != 4) return invalid_arguments;
540
541     const dims_t block_dims = {16, 16, 1, 1};
542     const int perm[] = {
543         0, 1, 2, 3,
544         5, 4, 6, 7};
545     return fill_contiguous_blocked(md, block_dims, perm);
546 }
547
548 status_t fill_OhIw8o4i(memory_desc_t &md) {
549     if (md.ndims != 4) return invalid_arguments;
550
551     const dims_t block_dims = {8, 4, 1, 1};
552     const int perm[] = {
553         0, 2, 1, 3,
554         4, 5, 6, 7};
555     return fill_contiguous_blocked(md, block_dims, perm);
556 }
557
558 status_t fill_OhIw8o32i(memory_desc_t &md) {
559     if (md.ndims != 4) return invalid_arguments;
560
561     const dims_t block_dims = {8, 32, 1, 1};
562     const int perm[] = {
563         0, 2, 1, 3,
564         4, 5, 6, 7};
565     return fill_contiguous_blocked(md, block_dims, perm);
566 }
567
568 status_t fill_OhIw16o32i(memory_desc_t &md) {
569     if (md.ndims != 4) return invalid_arguments;
570
571     const dims_t block_dims = {16, 32, 1, 1};
572     const int perm[] = {
573         0, 2, 1, 3,
574         4, 5, 6, 7};
575     return fill_contiguous_blocked(md, block_dims, perm);
576 }
577
578 status_t fill_OIhw8i16o2i(memory_desc_t &md) {
579     if (md.ndims != 4) return invalid_arguments;
580
581     const dims_t block_dims = {16, 16, 1, 1};
582     const int perm[] = {
583         0, 1, 2, 3,
584         5, 4, 6, 7};
585     return fill_contiguous_blocked(md, block_dims, perm);
586 }
587
588 status_t fill_OIdhw8i16o2i(memory_desc_t &md) {
589     if (md.ndims != 5) return invalid_arguments;
590
591     const dims_t block_dims = {16, 16, 1, 1, 1};
592     const int perm[] = {
593         0, 1, 2, 3, 4,
594         6, 5, 7, 8, 9};
595     return fill_contiguous_blocked(md, block_dims, perm);
596 }
597
598 status_t fill_OIhw8o8i(memory_desc_t &md) {
599     if (md.ndims != 4) return invalid_arguments;
600
601     const dims_t block_dims = {8, 8, 1, 1};
602     const int perm[] = {
603         0, 1, 2, 3,
604         4, 5, 6, 7};
605     return fill_contiguous_blocked(md, block_dims, perm);
606 }
607
608 status_t fill_OIhw16o16i(memory_desc_t &md) {
609     if (md.ndims != 4) return invalid_arguments;
610
611     const dims_t block_dims = {16, 16, 1, 1};
612     const int perm[] = {
613         0, 1, 2, 3,
614         4, 5, 6, 7};
615     return fill_contiguous_blocked(md, block_dims, perm);
616 }
617
618 status_t fill_OIdhw16o16i(memory_desc_t &md) {
619     if (md.ndims != 5) return invalid_arguments;
620
621     const dims_t block_dims = {16, 16, 1, 1, 1};
622     const int perm[] = {
623         0, 1, 2, 3, 4,
624         5, 6, 7, 8, 9};
625     return fill_contiguous_blocked(md, block_dims, perm);
626 }
627
628 status_t fill_OIdhw8o8i(memory_desc_t &md) {
629     if (md.ndims != 5) return invalid_arguments;
630
631     const dims_t block_dims = {8, 8, 1, 1, 1};
632     const int perm[] = {
633         0, 1, 2, 3, 4,
634         5, 6, 7, 8, 9};
635     return fill_contiguous_blocked(md, block_dims, perm);
636 }
637
638 status_t fill_IOhw16o16i(memory_desc_t &md) {
639     if (md.ndims != 4) return invalid_arguments;
640
641     const dims_t block_dims = {16, 16, 1, 1};
642     const int perm[] = {
643         1, 0, 2, 3,
644         4, 5, 6, 7};
645     return fill_contiguous_blocked(md, block_dims, perm);
646 }
647
648 status_t fill_OIhw8o16i2o(memory_desc_t &md) {
649     if (md.ndims != 4) return invalid_arguments;
650
651     const dims_t block_dims = {16, 16, 1, 1};
652     const int perm[] = {
653         0, 1, 2, 3,
654         4, 5, 6, 7};
655     return fill_contiguous_blocked(md, block_dims, perm);
656 }
657
658 status_t fill_Oihw4o(memory_desc_t &md) {
659     if (md.ndims != 4) return invalid_arguments;
660
661     const dims_t block_dims = {4, 1, 1, 1};
662     const int perm[] = {
663         0, 1, 2, 3,
664         4, 5, 6, 7};
665     return fill_contiguous_blocked(md, block_dims, perm);
666 }
667
668 status_t fill_Oihw16o(memory_desc_t &md) {
669     if (md.ndims != 4) return invalid_arguments;
670
671     const dims_t block_dims = { 16, 1, 1, 1 };
672     const int perm[] = {
673         0, 1, 2, 3,
674         4, 5, 6, 7 };
675     return fill_contiguous_blocked(md, block_dims, perm);
676 }
677
678 status_t fill_Oidhw4o(memory_desc_t &md) {
679     if (md.ndims != 5) return invalid_arguments;
680
681     const dims_t block_dims = { 4, 1, 1, 1, 1 };
682     const int perm[] = {
683         0, 1, 2, 3, 4,
684         5, 6, 7, 8, 9 };
685     return fill_contiguous_blocked(md, block_dims, perm);
686 }
687
688 status_t fill_Oidhw16o(memory_desc_t &md) {
689     if (md.ndims != 5) return invalid_arguments;
690
691     const dims_t block_dims = {16, 1, 1, 1, 1};
692     const int perm[] = {
693         0, 1, 2, 3, 4,
694         5, 6, 7, 8, 9};
695     return fill_contiguous_blocked(md, block_dims, perm);
696 }
697
698 status_t fill_Ohwi8o(memory_desc_t &md) {
699     if (md.ndims != 4) return invalid_arguments;
700
701     const dims_t block_dims = {8, 1, 1, 1};
702     const int perm[] = {
703         0, 2, 3, 1,
704         4, 5, 6, 7};
705     return fill_contiguous_blocked(md, block_dims, perm);
706 }
707
708 status_t fill_Ohwi4o(memory_desc_t &md) {
709     if (md.ndims != 4) return invalid_arguments;
710
711     const dims_t block_dims = {4, 1, 1, 1};
712     const int perm[] = {
713         0, 2, 3, 1,
714         4, 5, 6, 7};
715     return fill_contiguous_blocked(md, block_dims, perm);
716 }
717
718 status_t fill_Ohwi16o(memory_desc_t &md) {
719     if (md.ndims != 4) return invalid_arguments;
720
721     const dims_t block_dims = { 16, 1, 1, 1 };
722     const int perm[] = {
723         0, 2, 3, 1,
724         4, 5, 6, 7 };
725     return fill_contiguous_blocked(md, block_dims, perm);
726 }
727
728 status_t fill_Odhwi16o(memory_desc_t &md) {
729     if (md.ndims != 5) return invalid_arguments;
730
731     const dims_t block_dims = {16, 1, 1, 1, 1};
732     const int perm[] = {
733         0, 2, 3, 4, 1,
734         5, 6, 7, 8, 9};
735     return fill_contiguous_blocked(md, block_dims, perm);
736 }
737
738 status_t fill_Odhwi8o(memory_desc_t &md) {
739     if (md.ndims != 5) return invalid_arguments;
740
741     const dims_t block_dims = {8, 1, 1, 1, 1};
742     const int perm[] = {
743         0, 2, 3, 4, 1,
744         5, 6, 7, 8, 9};
745     return fill_contiguous_blocked(md, block_dims, perm);
746 }
747
748 status_t fill_goiw(memory_desc_t &md) {
749     if (md.ndims != 4) return invalid_arguments;
750
751     const int perm[4] = {0, 1, 2, 3};
752     return fill_nonblocked(md, perm);
753 }
754
755 status_t fill_gOwi4o(memory_desc_t &md) {
756     if (md.ndims != 4) return invalid_arguments;
757
758     const dims_t block_dims = {1, 4, 1, 1};
759     const int perm[] = {
760         0, 1, 3, 2,
761         4, 5, 6, 7};
762     return fill_contiguous_blocked(md, block_dims, perm);
763 }
764
765 status_t fill_gOwi8o(memory_desc_t &md) {
766     if (md.ndims != 4) return invalid_arguments;
767
768     const dims_t block_dims = { 1, 8, 1, 1 };
769     const int perm[] = {
770         0, 1, 3, 2,
771         4, 5, 6, 7 };
772     return fill_contiguous_blocked(md, block_dims, perm);
773 }
774
775 status_t fill_gOIw8o8i(memory_desc_t &md) {
776     if (md.ndims != 4) return invalid_arguments;
777
778     const dims_t block_dims = { 1, 8, 8, 1 };
779     const int perm[] = {
780         0, 1, 2, 3,
781         4, 5, 6, 7 };
782     return fill_contiguous_blocked(md, block_dims, perm);
783 }
784
785 status_t fill_gOIw4i4o(memory_desc_t &md) {
786     if (md.ndims != 4) return invalid_arguments;
787
788     const dims_t block_dims = { 1, 4, 4, 1 };
789     const int perm[] = {
790         0, 1, 2, 3,
791         4, 6, 5, 7 };
792     return fill_contiguous_blocked(md, block_dims, perm);
793 }
794
795 status_t fill_gOIw8i8o(memory_desc_t &md) {
796     if (md.ndims != 4) return invalid_arguments;
797
798     const dims_t block_dims = {1, 8, 8, 1};
799     const int perm[] = {
800         0, 1, 2, 3,
801         4, 6, 5, 7};
802     return fill_contiguous_blocked(md, block_dims, perm);
803 }
804
805 status_t fill_gOIw16i16o(memory_desc_t &md) {
806     if (md.ndims != 4) return invalid_arguments;
807
808     const dims_t block_dims = {1, 16, 16, 1};
809     const int perm[] = {
810         0, 1, 2, 3,
811         4, 6, 5, 7};
812     return fill_contiguous_blocked(md, block_dims, perm);
813 }
814
815 status_t fill_gOIw16o16i(memory_desc_t &md) {
816     if (md.ndims != 4) return invalid_arguments;
817
818     const dims_t block_dims = {1, 16, 16, 1};
819     const int perm[] = {
820         0, 1, 2, 3,
821         4, 5, 6, 7};
822     return fill_contiguous_blocked(md, block_dims, perm);
823 }
824
825 status_t fill_gOiw4o(memory_desc_t &md) {
826     if (md.ndims != 4) return invalid_arguments;
827
828     const dims_t block_dims = { 1, 4, 1, 1 };
829     const int perm[] = {
830         0, 1, 2, 3,
831         4, 5, 6, 7 };
832     return fill_contiguous_blocked(md, block_dims, perm);
833 }
834
835 status_t fill_gOiw16o(memory_desc_t &md) {
836     if (md.ndims != 4) return invalid_arguments;
837
838     const dims_t block_dims = {1, 16, 1, 1};
839     const int perm[] = {
840         0, 1, 2, 3,
841         4, 5, 6, 7};
842     return fill_contiguous_blocked(md, block_dims, perm);
843 }
844
845 status_t fill_gOwi16o(memory_desc_t &md) {
846     if (md.ndims != 4) return invalid_arguments;
847
848     const dims_t block_dims = {1, 16, 1, 1};
849     const int perm[] = {
850         0, 1, 3, 2,
851         4, 5, 6, 7};
852     return fill_contiguous_blocked(md, block_dims, perm);
853 }
854
855 status_t fill_gOIw8i16o2i(memory_desc_t &md) {
856     if (md.ndims != 4) return invalid_arguments;
857
858     const dims_t block_dims = {1, 16, 16, 1};
859     const int perm[] = {
860         0, 1, 2, 3,
861         4, 6, 5, 7};
862     return fill_contiguous_blocked(md, block_dims, perm);
863 }
864
865 status_t fill_gOIw8o16i2o(memory_desc_t &md) {
866     if (md.ndims != 4) return invalid_arguments;
867
868     const dims_t block_dims = {1, 16, 16, 1};
869     const int perm[] = {
870         0, 1, 2, 3,
871         4, 5, 6, 7};
872     return fill_contiguous_blocked(md, block_dims, perm);
873 }
874
875 status_t fill_gIOw16o16i(memory_desc_t &md) {
876     if (md.ndims != 4) return invalid_arguments;
877
878     const dims_t block_dims = {1, 16, 16, 1};
879     const int perm[] = {
880         0, 2, 1, 3,
881         4, 5, 6, 7};
882     return fill_contiguous_blocked(md, block_dims, perm);
883 }
884
885 status_t fill_goihw(memory_desc_t &md) {
886     if (md.ndims != 5) return invalid_arguments;
887
888     const int perm[5] = {0, 1, 2, 3, 4};
889     return fill_nonblocked(md, perm);
890 }
891
892 status_t fill_hwigo(memory_desc_t &md) {
893     if (md.ndims != 5) return invalid_arguments;
894
895     const int perm[5] = {3, 4, 2, 0, 1};
896     return fill_nonblocked(md, perm);
897 }
898
899 status_t fill_giohw(memory_desc_t &md) {
900     if (md.ndims != 5) return invalid_arguments;
901
902     const int perm[5] = {0, 2, 1, 3, 4};
903     return fill_nonblocked(md, perm);
904 }
905
906 status_t fill_gOIhw4o4i(memory_desc_t &md) {
907     if (md.ndims != 5) return invalid_arguments;
908
909     const dims_t block_dims = {1, 4, 4, 1, 1};
910     const int perm[] = {
911         0, 1, 2, 3, 4,
912         5, 6, 7, 8, 9};
913     return fill_contiguous_blocked(md, block_dims, perm);
914 }
915
916 status_t fill_gOIhw4i4o(memory_desc_t &md) {
917     if (md.ndims != 5) return invalid_arguments;
918
919     const dims_t block_dims = { 1, 4, 4, 1, 1 };
920     const int perm[] = {
921         0, 1, 2, 3, 4,
922         5, 7, 6, 8, 9 };
923     return fill_contiguous_blocked(md, block_dims, perm);
924 }
925
926 status_t fill_gOIhw8i8o(memory_desc_t &md) {
927     if (md.ndims != 5) return invalid_arguments;
928
929     const dims_t block_dims = { 1, 8, 8, 1, 1 };
930     const int perm[] = {
931         0, 1, 2, 3, 4,
932         5, 7, 6, 8, 9 };
933     return fill_contiguous_blocked(md, block_dims, perm);
934 }
935
936 status_t fill_gOIhw16i16o(memory_desc_t &md) {
937     if (md.ndims != 5) return invalid_arguments;
938
939     const dims_t block_dims = {1, 16, 16, 1, 1};
940     const int perm[] = {
941         0, 1, 2, 3, 4,
942         5, 7, 6, 8, 9};
943     return fill_contiguous_blocked(md, block_dims, perm);
944 }
945
946 status_t fill_gOIdhw16i16o(memory_desc_t &md) {
947     if (md.ndims != 6) return invalid_arguments;
948
949     const dims_t block_dims = {1, 16, 16, 1, 1, 1};
950     const int perm[] = {
951         0, 1, 2, 3, 4, 5,
952         6, 8, 7, 9, 10, 11};
953     return fill_contiguous_blocked(md, block_dims, perm);
954 }
955
956 status_t fill_gOIdhw4i4o(memory_desc_t &md) {
957     if (md.ndims != 6) return invalid_arguments;
958
959     const dims_t block_dims = {1, 4, 4, 1, 1, 1};
960     const int perm[] = {
961         0, 1, 2, 3, 4, 5,
962         6, 8, 7, 9, 10, 11};
963     return fill_contiguous_blocked(md, block_dims, perm);
964 }
965
966 status_t fill_gOIdhw8i8o(memory_desc_t &md) {
967     if (md.ndims != 6) return invalid_arguments;
968
969     const dims_t block_dims = { 1, 8, 8, 1, 1, 1 };
970     const int perm[] = {
971         0, 1, 2, 3, 4, 5,
972         6, 8, 7, 9, 10, 11 };
973     return fill_contiguous_blocked(md, block_dims, perm);
974 }
975
976 status_t fill_gOihw4o(memory_desc_t &md) {
977     if (md.ndims != 5) return invalid_arguments;
978
979     const dims_t block_dims = {1, 4, 1, 1, 1};
980     const int perm[] = {
981         0, 1, 2, 3, 4,
982         5, 6, 7, 8, 9};
983     return fill_contiguous_blocked(md, block_dims, perm);
984 }
985
986 status_t fill_gOihw16o(memory_desc_t &md) {
987     if (md.ndims != 5) return invalid_arguments;
988
989     const dims_t block_dims = { 1, 16, 1, 1, 1 };
990     const int perm[] = {
991         0, 1, 2, 3, 4,
992         5, 6, 7, 8, 9 };
993     return fill_contiguous_blocked(md, block_dims, perm);
994 }
995
996 status_t fill_gOidhw4o(memory_desc_t &md) {
997     if (md.ndims != 6) return invalid_arguments;
998
999     const dims_t block_dims = {1, 4, 1, 1, 1, 1};
1000     const int perm[] = {
1001         0, 1, 2, 3, 4, 5,
1002         6, 7, 8, 9, 10, 11};
1003     return fill_contiguous_blocked(md, block_dims, perm);
1004 }
1005
1006 status_t fill_gOidhw16o(memory_desc_t &md) {
1007     if (md.ndims != 6) return invalid_arguments;
1008
1009     const dims_t block_dims = { 1, 16, 1, 1, 1, 1 };
1010     const int perm[] = {
1011         0, 1, 2, 3, 4, 5,
1012         6, 7, 8, 9, 10, 11 };
1013     return fill_contiguous_blocked(md, block_dims, perm);
1014 }
1015
1016 status_t fill_gOhwi8o(memory_desc_t &md) {
1017     if (md.ndims != 5) return invalid_arguments;
1018
1019     const dims_t block_dims = {1, 8, 1, 1, 1};
1020     const int perm[] = {
1021         0, 1, 3, 4, 2,
1022         5, 6, 7, 8, 9};
1023     return fill_contiguous_blocked(md, block_dims, perm);
1024 }
1025
1026 status_t fill_gOhwi4o(memory_desc_t &md) {
1027     if (md.ndims != 5) return invalid_arguments;
1028
1029     const dims_t block_dims = {1, 4, 1, 1, 1};
1030     const int perm[] = {
1031         0, 1, 3, 4, 2,
1032         5, 6, 7, 8, 9};
1033     return fill_contiguous_blocked(md, block_dims, perm);
1034 }
1035
1036 status_t fill_gOhwi16o(memory_desc_t &md) {
1037     if (md.ndims != 5) return invalid_arguments;
1038
1039     const dims_t block_dims = { 1, 16, 1, 1, 1 };
1040     const int perm[] = {
1041         0, 1, 3, 4, 2,
1042         5, 6, 7, 8, 9 };
1043     return fill_contiguous_blocked(md, block_dims, perm);
1044 }
1045
1046 status_t fill_gOdhwi16o(memory_desc_t &md) {
1047     if (md.ndims != 6) return invalid_arguments;
1048
1049     const dims_t block_dims = {1, 16, 1, 1, 1, 1};
1050     const int perm[] = {
1051         0, 1, 3, 4, 5, 2,
1052         6, 7, 8, 9, 10, 11};
1053     return fill_contiguous_blocked(md, block_dims, perm);
1054 }
1055
1056 status_t fill_gOdhwi8o(memory_desc_t &md) {
1057     if (md.ndims != 6) return invalid_arguments;
1058
1059     const dims_t block_dims = {1, 8, 1, 1, 1, 1};
1060     const int perm[] = {
1061         0, 1, 3, 4, 5, 2,
1062         6, 7, 8, 9, 10, 11};
1063     return fill_contiguous_blocked(md, block_dims, perm);
1064 }
1065
1066 status_t fill_gOIhw4i16o4i(memory_desc_t &md) {
1067     if (md.ndims != 5) return invalid_arguments;
1068
1069     const dims_t block_dims = {1, 16, 16, 1, 1};
1070     const int perm[] = {
1071         0, 1, 2, 3, 4,
1072         5, 7, 6, 8, 9};
1073     return fill_contiguous_blocked(md, block_dims, perm);
1074 }
1075
1076 status_t fill_gOIhw2i8o4i(memory_desc_t &md) {
1077     if (md.ndims != 5) return invalid_arguments;
1078
1079     const dims_t block_dims = {1, 8, 8, 1, 1};
1080     const int perm[] = {
1081         0, 1, 2, 3, 4,
1082         5, 7, 6, 8, 9};
1083     return fill_contiguous_blocked(md, block_dims, perm);
1084 }
1085
1086 status_t fill_gOhIw8o4i(memory_desc_t &md) {
1087     if (md.ndims != 5) return invalid_arguments;
1088
1089     const dims_t block_dims = {1, 8, 4, 1, 1};
1090     const int perm[] = {
1091         0, 1, 3, 2, 4,
1092         5, 6, 7, 8, 9};
1093     return fill_contiguous_blocked(md, block_dims, perm);
1094 }
1095
1096 status_t fill_Goihw8g(memory_desc_t &md) {
1097     if (md.ndims != 5) return invalid_arguments;
1098
1099     const dims_t block_dims = {8, 1, 1, 1, 1};
1100     const int perm[] = {
1101          0, 1, 2, 3, 4,
1102          5, 6, 7, 8, 9};
1103     return fill_contiguous_blocked(md, block_dims, perm);
1104 }
1105
1106 status_t fill_Goihw16g(memory_desc_t &md) {
1107     if (md.ndims != 5) return invalid_arguments;
1108
1109     const dims_t block_dims = {16, 1, 1, 1, 1};
1110     const int perm[] = {
1111          0, 1, 2, 3, 4,
1112          5, 6, 7, 8, 9};
1113     return fill_contiguous_blocked(md, block_dims, perm);
1114 }
1115
1116 status_t fill_gOIhw8i16o2i(memory_desc_t &md) {
1117     if (md.ndims != 5) return invalid_arguments;
1118
1119     const dims_t block_dims = {1, 16, 16, 1, 1};
1120     const int perm[] = {
1121         0, 1, 2, 3, 4,
1122         5, 7, 6, 8, 9};
1123     return fill_contiguous_blocked(md, block_dims, perm);
1124 }
1125
1126 status_t fill_gOIdhw8i16o2i(memory_desc_t &md) {
1127     if (md.ndims != 6) return invalid_arguments;
1128
1129     const dims_t block_dims = {1, 16, 16, 1, 1, 1};
1130     const int perm[] = {
1131         0, 1, 2, 3, 4, 5,
1132         6, 8, 7, 9, 10, 11};
1133     return fill_contiguous_blocked(md, block_dims, perm);
1134 }
1135
1136 status_t fill_gOIhw8o8i(memory_desc_t &md) {
1137     if (md.ndims != 5) return invalid_arguments;
1138
1139     const dims_t block_dims = {1, 8, 8, 1, 1};
1140     const int perm[] = {
1141         0, 1, 2, 3, 4,
1142         5, 6, 7, 8, 9};
1143     return fill_contiguous_blocked(md, block_dims, perm);
1144 }
1145
1146 status_t fill_gOIhw16o16i(memory_desc_t &md) {
1147     if (md.ndims != 5) return invalid_arguments;
1148
1149     const dims_t block_dims = {1, 16, 16, 1, 1};
1150     const int perm[] = {
1151         0, 1, 2, 3, 4,
1152         5, 6, 7, 8, 9};
1153     return fill_contiguous_blocked(md, block_dims, perm);
1154 }
1155
1156 status_t fill_gOIdhw16o16i(memory_desc_t &md) {
1157     if (md.ndims != 6) return invalid_arguments;
1158
1159     const dims_t block_dims = {1, 16, 16, 1, 1, 1};
1160     const int perm[] = {
1161         0, 1, 2, 3, 4, 5,
1162         6, 7, 8, 9, 10, 11};
1163     return fill_contiguous_blocked(md, block_dims, perm);
1164 }
1165
1166 status_t fill_gOIdhw8o8i(memory_desc_t &md) {
1167     if (md.ndims != 6) return invalid_arguments;
1168
1169     const dims_t block_dims = {1, 8, 8, 1, 1, 1};
1170     const int perm[] = {
1171         0, 1, 2, 3, 4, 5,
1172         6, 7, 8, 9, 10, 11};
1173     return fill_contiguous_blocked(md, block_dims, perm);
1174 }
1175
1176 status_t fill_gIOhw16o16i(memory_desc_t &md) {
1177     if (md.ndims != 5) return invalid_arguments;
1178
1179     const dims_t block_dims = {1, 16, 16, 1, 1};
1180     const int perm[] = {
1181         0, 2, 1, 3, 4,
1182         5, 6, 7, 8, 9};
1183     return fill_contiguous_blocked(md, block_dims, perm);
1184 }
1185
1186 status_t fill_gOIhw8o16i2o(memory_desc_t &md) {
1187     if (md.ndims != 5) return invalid_arguments;
1188
1189     const dims_t block_dims = {1, 16, 16, 1, 1};
1190     const int perm[] = {
1191         0, 1, 2, 3, 4,
1192         5, 6, 7, 8, 9};
1193     return fill_contiguous_blocked(md, block_dims, perm);
1194 }
1195
1196 status_t fill_ntc(memory_desc_t &md) {
1197     if (md.ndims != 3) return invalid_arguments;
1198
1199     const int perm[3] = { 1, 0, 2 };
1200     return fill_nonblocked(md, perm);
1201 }
1202
1203 status_t fill_tnc(memory_desc_t &md) {
1204     if (md.ndims != 3) return invalid_arguments;
1205     const int perm[3] = { 0, 1, 2 };
1206     return fill_nonblocked(md, perm);
1207 }
1208
1209 status_t fill_ldsnc(memory_desc_t &md) {
1210     if (md.ndims != 5) return invalid_arguments;
1211     const int perm[5] = { 0, 1, 2, 3, 4 };
1212     return fill_nonblocked(md, perm);
1213 }
1214
1215 status_t fill_ldigo(memory_desc_t &md) {
1216     if (md.ndims != 5) return invalid_arguments;
1217
1218     const int perm[5] = { 0, 1, 2, 3, 4 };
1219     return fill_nonblocked(md, perm);
1220 }
1221
1222 status_t fill_ldgoi(memory_desc_t &md) {
1223     if (md.ndims != 5) return invalid_arguments;
1224
1225     const int perm[5] = { 0, 1, 3, 4, 2 };
1226     return fill_nonblocked(md, perm);
1227 }
1228
1229 status_t fill_ldgo(memory_desc_t &md) {
1230     if (md.ndims != 4) return invalid_arguments;
1231
1232     const int perm[4] = { 0, 1, 2, 3 };
1233     return fill_nonblocked(md, perm);
1234 }
1235
1236 }
1237
1238 status_t memory_desc_wrapper::compute_blocking(memory_desc_t &memory_desc)
1239 {
1240     if (memory_desc.ndims == 0) return invalid_arguments;
1241
1242     switch (memory_desc.format) {
1243     case x: return fill_x(memory_desc);
1244     case nc: return fill_nc(memory_desc);
1245     case ncw: return fill_ncw(memory_desc);
1246     case nwc: return fill_nwc(memory_desc);
1247     case nCw4c: return fill_nCw4c(memory_desc);
1248     case nCw8c: return fill_nCw8c(memory_desc);
1249     case nCw16c: return fill_nCw16c(memory_desc);
1250     case nchw: return fill_nchw(memory_desc);
1251     case nhwc: return fill_nhwc(memory_desc);
1252     case chwn: return fill_chwn(memory_desc);
1253     case nChw4c: return fill_nChw4c(memory_desc);
1254     case nChw8c: case oIhw8i: return fill_nChw8c(memory_desc);
1255     case nChw16c: case oIhw16i: return fill_nChw16c(memory_desc);
1256     case oi: return fill_oi(memory_desc);
1257     case io: return fill_io(memory_desc);
1258     case oiw: return fill_oiw(memory_desc);
1259     case wio: return fill_wio(memory_desc);
1260     case Owi4o: return fill_Owi4o(memory_desc);
1261     case OIw4i4o: return fill_OIw4i4o(memory_desc);
1262     case Owi8o: return fill_Owi8o(memory_desc);
1263     case OIw8o8i: return fill_OIw8o8i(memory_desc);
1264     case OIw8i8o: return fill_OIw8i8o(memory_desc);
1265     case OIw16i16o: return fill_OIw16i16o(memory_desc);
1266     case OIw16o16i: return fill_OIw16o16i(memory_desc);
1267     case Oiw4o: return fill_Oiw4o(memory_desc);
1268     case Oiw16o: return fill_Oiw16o(memory_desc);
1269     case Owi16o: return fill_Owi16o(memory_desc);
1270     case OIw8i16o2i: return fill_OIw8i16o2i(memory_desc);
1271     case OIw8o16i2o: return fill_OIw8o16i2o(memory_desc);
1272     case IOw16o16i: return fill_IOw16o16i(memory_desc);
1273     case oihw: return fill_oihw(memory_desc);
1274     case ihwo: return fill_ihwo(memory_desc);
1275     case hwio: return fill_hwio(memory_desc);
1276     case iohw: return fill_iohw(memory_desc);
1277     case hwio_s8s8: return fill_hwio(memory_desc);
1278     case dhwio: return fill_dhwio(memory_desc);
1279     case OIhw4i4o: return fill_OIhw4i4o(memory_desc);
1280     case OIhw8i8o: return fill_OIhw8i8o(memory_desc);
1281     case OIhw16i16o: return fill_OIhw16i16o(memory_desc);
1282     case OIhw4i16o4i: return fill_OIhw4i16o4i(memory_desc);
1283     case OhIw8o4i: return fill_OhIw8o4i(memory_desc);
1284     case OhIw8o32i: return fill_OhIw8o32i(memory_desc);
1285     case OhIw16o32i: return fill_OhIw16o32i(memory_desc);
1286     case OhIw8o4i_s8s8: return fill_OhIw8o4i(memory_desc);
1287     case OIhw4i16o4i_s8s8: return fill_OIhw4i16o4i(memory_desc);
1288     case OIhw8i16o2i: return fill_OIhw8i16o2i(memory_desc);
1289     case OIdhw8i16o2i: return fill_OIdhw8i16o2i(memory_desc);
1290     case OIhw8o16i2o: return fill_OIhw8o16i2o(memory_desc);
1291     case OIhw8o8i: return fill_OIhw8o8i(memory_desc);
1292     case OIhw16o16i: return fill_OIhw16o16i(memory_desc);
1293     case IOhw16o16i: return fill_IOhw16o16i(memory_desc);
1294     case Oihw4o: return fill_Oihw4o(memory_desc);
1295     case Oihw16o: return fill_Oihw16o(memory_desc);
1296     case Ohwi8o: return fill_Ohwi8o(memory_desc);
1297     case Ohwi4o: return fill_Ohwi4o(memory_desc);
1298     case Ohwi16o: return fill_Ohwi16o(memory_desc);
1299     case goiw: return fill_goiw(memory_desc);
1300     case gOwi4o: return fill_gOwi4o(memory_desc);
1301     case gOIw4i4o: return fill_gOIw4i4o(memory_desc);
1302     case gOwi8o: return fill_gOwi8o(memory_desc);
1303     case gOIw8o8i: return fill_gOIw8o8i(memory_desc);
1304     case gOIw8i8o: return fill_gOIw8i8o(memory_desc);
1305     case gOIw16i16o: return fill_gOIw16i16o(memory_desc);
1306     case gOIw16o16i: return fill_gOIw16o16i(memory_desc);
1307     case gOiw4o: return fill_gOiw4o(memory_desc);
1308     case gOiw16o: return fill_gOiw16o(memory_desc);
1309     case gOwi16o: return fill_gOwi16o(memory_desc);
1310     case gOIw8i16o2i: return fill_gOIw8i16o2i(memory_desc);
1311     case gOIw8o16i2o: return fill_gOIw8o16i2o(memory_desc);
1312     case gIOw16o16i: return fill_gIOw16o16i(memory_desc);
1313     case goihw: return fill_goihw(memory_desc);
1314     case hwigo: return fill_hwigo(memory_desc);
1315     case giohw: return fill_giohw(memory_desc);
1316     case hwigo_s8s8: return fill_hwigo(memory_desc);
1317     case gOIhw4i4o: return fill_gOIhw4i4o(memory_desc);
1318     case gOIhw8i8o: return fill_gOIhw8i8o(memory_desc);
1319     case gOIhw16i16o: return fill_gOIhw16i16o(memory_desc);
1320     case gOIhw4i16o4i: return fill_gOIhw4i16o4i(memory_desc);
1321     case gOhIw8o4i: return fill_gOhIw8o4i(memory_desc);
1322     case gOhIw8o4i_s8s8: return fill_gOhIw8o4i(memory_desc);
1323     case gOIhw4i16o4i_s8s8: return fill_gOIhw4i16o4i(memory_desc);
1324     case gOIhw2i8o4i: return fill_gOIhw2i8o4i(memory_desc);
1325     case gOIhw2i8o4i_s8s8: return fill_gOIhw2i8o4i(memory_desc);
1326     case gOIhw8i16o2i: return fill_gOIhw8i16o2i(memory_desc);
1327     case gOIdhw8i16o2i: return fill_gOIdhw8i16o2i(memory_desc);
1328     case gOIhw8o16i2o: return fill_gOIhw8o16i2o(memory_desc);
1329     case gOIhw4o4i: return fill_gOIhw4o4i(memory_desc);
1330     case gOIhw4o4i_s8s8: return fill_gOIhw4o4i(memory_desc);
1331     case gOIhw8o8i: return fill_gOIhw8o8i(memory_desc);
1332     case gOIhw16o16i: return fill_gOIhw16o16i(memory_desc);
1333     case gIOhw16o16i: return fill_gIOhw16o16i(memory_desc);
1334     case gOihw4o: return fill_gOihw4o(memory_desc);
1335     case gOihw16o: return fill_gOihw16o(memory_desc);
1336     case gOhwi8o: return fill_gOhwi8o(memory_desc);
1337     case gOhwi4o: return fill_gOhwi4o(memory_desc);
1338     case gOhwi16o: return fill_gOhwi16o(memory_desc);
1339     case Goihw8g: return fill_Goihw8g(memory_desc);
1340     case Goihw16g: return fill_Goihw16g(memory_desc);
1341     case Goihw16g_s8s8: return fill_Goihw16g(memory_desc);
1342     case ncdhw: return fill_ncdhw(memory_desc);
1343     case ndhwc: return fill_ndhwc(memory_desc);
1344     case oidhw: return fill_oidhw(memory_desc);
1345     case goidhw: return fill_goidhw(memory_desc);
1346     case nCdhw4c: return fill_nCdhw4c(memory_desc);
1347     case nCdhw8c: case oIdhw8i: return fill_nCdhw8c(memory_desc);
1348     case nCdhw16c: case oIdhw16i: return fill_nCdhw16c(memory_desc);
1349     case OIdhw16i16o: return fill_OIdhw16i16o(memory_desc);
1350     case gOIdhw16i16o: return fill_gOIdhw16i16o(memory_desc);
1351     case OIdhw4i4o: return fill_OIdhw4i4o(memory_desc);
1352     case gOIdhw4i4o: return fill_gOIdhw4i4o(memory_desc);
1353     case OIdhw8i8o: return fill_OIdhw8i8o(memory_desc);
1354     case gOIdhw8i8o: return fill_gOIdhw8i8o(memory_desc);
1355     case OIdhw16o16i: return fill_OIdhw16o16i(memory_desc);
1356     case gOIdhw16o16i: return fill_gOIdhw16o16i(memory_desc);
1357     case OIdhw8o8i: return fill_OIdhw8o8i(memory_desc);
1358     case gOIdhw8o8i: return fill_gOIdhw8o8i(memory_desc);
1359     case Oidhw4o: return fill_Oidhw4o(memory_desc);
1360     case Oidhw16o: return fill_Oidhw16o(memory_desc);
1361     case Odhwi16o: return fill_Odhwi16o(memory_desc);
1362     case Odhwi8o: return fill_Odhwi8o(memory_desc);
1363     case gOidhw4o: return fill_gOidhw4o(memory_desc);
1364     case gOidhw16o: return fill_gOidhw16o(memory_desc);
1365     case gOdhwi16o: return fill_gOdhwi16o(memory_desc);
1366     case gOdhwi8o: return fill_gOdhwi8o(memory_desc);
1367     case ntc: return fill_ntc(memory_desc);
1368     case tnc: return fill_tnc(memory_desc);
1369     case ldsnc: return fill_ldsnc(memory_desc);
1370     case ldigo: return fill_ldigo(memory_desc);
1371     case ldgoi: return fill_ldgoi(memory_desc);
1372     case ldgo: return fill_ldgo(memory_desc);
1373     case wino_fmt:
1374     case rnn_packed: return success;
1375     default: break;
1376     }
1377
1378     return invalid_arguments;
1379 }
1380
1381 }
1382 }
1383
1384 // vim: et ts=4 sw=4 cindent cino^=l0,\:0,N-s