Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / include / to_string_utils.h
1 /*
2 // Copyright (c) 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 #pragma once
17 #include <string>
18 #include "api/CPP/tensor.hpp"
19 #include "api/CPP/layout.hpp"
20
21 namespace cldnn
22 {
23
24 inline std::string bool_to_str(bool cond)
25 {
26     return cond ? "true" : "false";
27 }
28
29 inline std::string get_extr_type(const std::string& str)
30 {
31     auto begin = str.find('<');
32     auto end = str.find('>');
33
34     if (begin == std::string::npos || end == std::string::npos)
35         return {};
36
37     return str.substr(begin + 1, (end - begin) -1);
38 }
39
40 inline std::string dt_to_str(data_types dt)
41 {
42     switch (dt)
43     {
44     case data_types::i8: return "i8";
45     case data_types::u8: return "u8";
46     case data_types::i32: return "i32";
47     case data_types::i64: return "i64";
48     case data_types::f16: return "f16";
49     case data_types::f32: return "f32";
50     default:
51         return "unknown (" + std::to_string(typename std::underlying_type<data_types>::type(dt)) + ")";
52     }
53 }
54
55 inline std::string fmt_to_str(format fmt)
56 {
57     switch (fmt.value)
58     {
59     case format::yxfb: return "yxfb";
60     case format::byxf: return "byxf";
61     case format::bfyx: return "bfyx";
62     case format::fyxb: return "fyxb";
63     case format::os_iyx_osv16: return "os_iyx_osv16";
64     case format::os_iyx_osv32: return "os_iyx_osv32";
65     case format::os_iyx_osv64: return "os_iyx_osv64";
66     case format::bs_xs_xsv8_bsv8: return "bs_xs_xsv8_bsv8";
67     case format::bs_xs_xsv8_bsv16: return "bs_xs_xsv8_bsv16";
68     case format::bs_x_bsv16: return "bs_x_bsv16";
69     case format::bf8_xy16: return "bf8_xy16";
70     case format::image_2d_weights_c4_fyx_b: return "image_2d_weights_c4_fyx_b";
71     case format::image_2d_weights_c1_b_fyx: return "image_2d_weights_c1_b_fyx";
72     case format::winograd_2x3_s1_data: return "winograd_2x3_s1_data";
73     case format::winograd_2x3_s1_weights: return "winograd_2x3_s1_weights";
74     case format::winograd_2x3_s1_fused_weights: return "winograd_2x3_s1_fused_weights";
75     case format::winograd_6x3_s1_fused_weights: return "winograd_6x3_s1_fused_weights";
76     case format::image_2d_weights_winograd_6x3_s1_fbxyb: return "image_2d_weights_winograd_6x3_s1_fbxyb";
77     case format::image_2d_weights_winograd_6x3_s1_xfbyb: return "image_2d_weights_winograd_6x3_s1_xfbyb";
78     case format::os_is_yx_isa8_osv8_isv4: return "os_is_yx_isa8_osv8_isv4";
79     case format::os_is_yx_isa8_osv8_isv4_swizzled_by_4: return "os_is_yx_isa8_osv8_isv4_swizzled_by_4";
80     case format::is_o_yx_isv32: return "is_o_yx_isv32";
81     case format::is_o32_yx_isv32_swizzled_by_4: return "is_o32_yx_isv32_swizzled_by_4";
82     case format::os_is_y_x8_osv8_isv4: return "os_is_y_x8_osv8_isv4";
83     case format::byxf_af32: return "byxf_af32";
84     case format::byx8_f4: return "byx8_f4";
85     case format::fs_bs_yx_bsv4_fsv32: return "fs_bs_yx_bsv4_fsv32";
86     case format::bf_lyx_yx: return "bf_lyx_yx";
87     case format::b_fs_yx_fsv4: return "b_fs_yx_fs4"; break;
88     case format::os_is_yx_osv16_isv4: return "os_is_yx_osv16_isv4"; break;
89     default:
90         return "unknown (" + std::to_string(fmt.value) + ")";
91     }
92 }
93
94 }
95