Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / tests / benchdnn / mkldnn_debug.cpp
1 /*******************************************************************************
2 * Copyright 2017-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 "mkldnn_debug.h"
18
19 #include "common.hpp"
20 #include "mkldnn_debug.hpp"
21
22 const char *status2str(mkldnn_status_t status) {
23     return mkldnn_status2str(status);
24 }
25
26 const char *dt2str(mkldnn_data_type_t dt) {
27     return mkldnn_dt2str(dt);
28 }
29
30 mkldnn_data_type_t str2dt(const char *str) {
31 #define CASE(_dt) \
32     if (!strcasecmp(STRINGIFY(_dt), str) \
33             || !strcasecmp(STRINGIFY(CONCAT2(mkldnn_, _dt)), str)) \
34         return CONCAT2(mkldnn_, _dt);
35     CASE(s8);
36     CASE(u8);
37     CASE(s16);
38     CASE(s32);
39     CASE(f32);
40 #undef CASE
41     assert(!"unknown data type");
42     return mkldnn_f32;
43 }
44
45 const char *rmode2str(mkldnn_round_mode_t rmode) {
46 #define CASE(_rmode) \
47     if (CONCAT2(mkldnn_round_, _rmode) == rmode) return STRINGIFY(_rmode)
48     CASE(nearest);
49     CASE(down);
50 #undef CASE
51     assert(!"unknown round mode");
52     return "unknown round mode";
53 }
54
55 mkldnn_round_mode_t str2rmode(const char *str) {
56 #define CASE(_rmd) do { \
57     if (!strncasecmp(STRINGIFY(_rmd), str, strlen(STRINGIFY(_rmd)))) \
58         return CONCAT2(mkldnn_round_, _rmd); \
59 } while (0)
60     CASE(nearest);
61     CASE(down);
62 #undef CASE
63     assert(!"unknown round_mode");
64     return mkldnn_round_nearest;
65 }
66
67 const char *fmt2str(mkldnn_memory_format_t fmt) {
68     return mkldnn_fmt2str(fmt);
69 }
70
71 mkldnn_memory_format_t str2fmt(const char *str) {
72 #define CASE(_fmt) do { \
73     if (!strcmp(STRINGIFY(_fmt), str) \
74             || !strcmp("mkldnn_" STRINGIFY(_fmt), str)) \
75         return CONCAT2(mkldnn_, _fmt); \
76 } while (0)
77     CASE(x);
78     CASE(nc);
79     CASE(ncw);
80     CASE(nwc);
81     CASE(nCw8c);
82     CASE(nCw16c);
83     CASE(nchw);
84     CASE(nhwc);
85     CASE(chwn);
86     CASE(nChw8c);
87     CASE(nChw16c);
88     CASE(oi);
89     CASE(io);
90     CASE(oiw);
91     CASE(wio);
92     CASE(OIw16i16o);
93     CASE(OIw16o16i);
94     CASE(Oiw16o);
95     CASE(Owi16o);
96     CASE(OIw8i16o2i);
97     CASE(oihw);
98     CASE(ihwo);
99     CASE(hwio);
100     CASE(iohw);
101     CASE(hwio_s8s8);
102     CASE(dhwio);
103     CASE(OIhw8i8o);
104     CASE(OIhw16i16o);
105     CASE(OIhw8i16o2i);
106     CASE(OIdhw8i16o2i);
107     CASE(OIhw4i16o4i);
108     CASE(OIhw4i16o4i_s8s8);
109     CASE(OIhw8o16i2o);
110     CASE(OIhw8o8i);
111     CASE(OIhw16o16i);
112     CASE(IOhw16o16i);
113     CASE(Oihw16o);
114     CASE(Ohwi8o);
115     CASE(Ohwi16o);
116     CASE(goiw);
117     CASE(goihw);
118     CASE(hwigo);
119     CASE(giohw);
120     CASE(hwigo_s8s8);
121     CASE(goiw);
122     CASE(gOIw16i16o);
123     CASE(gOIw16o16i);
124     CASE(gOiw16o);
125     CASE(gOwi16o);
126     CASE(gOIw8i16o2i);
127     CASE(gOIhw8i8o);
128     CASE(gOIhw16i16o);
129     CASE(gOIhw8i16o2i);
130     CASE(gOIdhw8i16o2i);
131     CASE(gOIhw4i16o4i);
132     CASE(gOIhw4i16o4i_s8s8);
133     CASE(gOIhw8o16i2o);
134     CASE(gOIhw8o8i);
135     CASE(gOIhw16o16i);
136     CASE(gIOhw16o16i);
137     CASE(gOihw16o);
138     CASE(gOhwi8o);
139     CASE(gOhwi16o);
140     CASE(Goihw8g);
141     CASE(Goihw16g);
142     CASE(Goihw16g_s8s8);
143     CASE(oIhw8i);
144     CASE(oIhw16i);
145     CASE(ncdhw);
146     CASE(ndhwc);
147     CASE(oidhw);
148     CASE(goidhw);
149     CASE(nCdhw8c);
150     CASE(nCdhw16c);
151     CASE(OIdhw16i16o);
152     CASE(gOIdhw16i16o);
153     CASE(OIdhw16o16i);
154     CASE(gOIdhw16o16i);
155     CASE(Oidhw16o);
156     CASE(Odhwi16o);
157     CASE(gOidhw16o);
158     CASE(gOdhwi16o);
159     CASE(ntc);
160     CASE(tnc);
161     CASE(ldsnc);
162     CASE(ldigo);
163     CASE(ldgoi);
164     CASE(ldgo);
165 #undef CASE
166     assert(!"unknown memory format");
167     return mkldnn_format_undef;
168 }