Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / include / to_string_utils.h
1 /*
2 // Copyright (c) 2017 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 "program_node.h"
19
20 namespace cldnn
21 {
22
23 inline std::string bool_to_str(const bool condi)
24 {
25         if (condi)
26         {
27                 return "true";
28         }
29         return "false";
30 }
31
32 inline std::string get_extr_type(const char* str)
33 {
34     if (!str)
35     {
36         return{};
37     }
38
39     while (*str && *str != '<')
40     {
41         ++str;
42     }
43     if (!*str)
44     {
45         return{};
46     }
47
48     auto end = str;
49     while (*end && *end != '>')
50     {
51         ++end;
52     }
53     if (!*end)
54     {
55         return{};
56     }
57
58     return{ str + 1, end };
59 }
60
61 inline std::string dt_to_str(data_types dt)
62 {
63     switch (dt)
64     {
65     case data_types::i8: return "i8";
66     case data_types::f16: return "f16";
67     case data_types::f32: return "f32";
68     default:
69         return "unknown (" + std::to_string(std::underlying_type_t<data_types>(dt)) + ")";
70     }
71 }
72
73 inline std::string fmt_to_str(format fmt)
74 {
75     switch (fmt.value)
76     {
77     case format::bfyx: return "bfyx";
78     case format::byxf: return "byxf";
79     case format::yxfb: return "yxfb";
80     case format::fyxb: return "fyxb";
81     case format::bs_x_bsv16: return "bs_x_bsv16";
82     case format::bs_xs_xsv8_bsv8: return "bs_xs_xsv8_bsv8";
83     case format::bs_xs_xsv8_bsv16: return "bs_xs_xsv8_bsv16";
84     case format::os_iyx_osv16: return "os_iyx_osv16";
85     case format::os_is_yx_isa8_osv8_isv4: return "os_is_yx_isa8_osv8_isv4";
86     case format::byxf_af32: return "byxf_af32";
87     default:
88         return "unknown (" + std::to_string(fmt.value) + ")";
89     }
90 }
91
92 }
93