1 | // GENERATED FILE - DO NOT MODIFY |
2 | |
3 | #include <algorithm> |
4 | |
5 | #include "tensorflow/core/framework/types.pb_text-impl.h" |
6 | |
7 | using ::tensorflow::strings::ProtoSpaceAndComments; |
8 | using ::tensorflow::strings::Scanner; |
9 | using ::tensorflow::strings::StrCat; |
10 | |
11 | namespace tensorflow { |
12 | |
13 | const char* EnumName_DataType( |
14 | ::tensorflow::DataType value) { |
15 | switch (value) { |
16 | case 0: return "DT_INVALID" ; |
17 | case 1: return "DT_FLOAT" ; |
18 | case 2: return "DT_DOUBLE" ; |
19 | case 3: return "DT_INT32" ; |
20 | case 4: return "DT_UINT8" ; |
21 | case 5: return "DT_INT16" ; |
22 | case 6: return "DT_INT8" ; |
23 | case 7: return "DT_STRING" ; |
24 | case 8: return "DT_COMPLEX64" ; |
25 | case 9: return "DT_INT64" ; |
26 | case 10: return "DT_BOOL" ; |
27 | case 11: return "DT_QINT8" ; |
28 | case 12: return "DT_QUINT8" ; |
29 | case 13: return "DT_QINT32" ; |
30 | case 14: return "DT_BFLOAT16" ; |
31 | case 15: return "DT_QINT16" ; |
32 | case 16: return "DT_QUINT16" ; |
33 | case 17: return "DT_UINT16" ; |
34 | case 18: return "DT_COMPLEX128" ; |
35 | case 19: return "DT_HALF" ; |
36 | case 20: return "DT_RESOURCE" ; |
37 | case 21: return "DT_VARIANT" ; |
38 | case 22: return "DT_UINT32" ; |
39 | case 23: return "DT_UINT64" ; |
40 | case 101: return "DT_FLOAT_REF" ; |
41 | case 102: return "DT_DOUBLE_REF" ; |
42 | case 103: return "DT_INT32_REF" ; |
43 | case 104: return "DT_UINT8_REF" ; |
44 | case 105: return "DT_INT16_REF" ; |
45 | case 106: return "DT_INT8_REF" ; |
46 | case 107: return "DT_STRING_REF" ; |
47 | case 108: return "DT_COMPLEX64_REF" ; |
48 | case 109: return "DT_INT64_REF" ; |
49 | case 110: return "DT_BOOL_REF" ; |
50 | case 111: return "DT_QINT8_REF" ; |
51 | case 112: return "DT_QUINT8_REF" ; |
52 | case 113: return "DT_QINT32_REF" ; |
53 | case 114: return "DT_BFLOAT16_REF" ; |
54 | case 115: return "DT_QINT16_REF" ; |
55 | case 116: return "DT_QUINT16_REF" ; |
56 | case 117: return "DT_UINT16_REF" ; |
57 | case 118: return "DT_COMPLEX128_REF" ; |
58 | case 119: return "DT_HALF_REF" ; |
59 | case 120: return "DT_RESOURCE_REF" ; |
60 | case 121: return "DT_VARIANT_REF" ; |
61 | case 122: return "DT_UINT32_REF" ; |
62 | case 123: return "DT_UINT64_REF" ; |
63 | default: return "" ; |
64 | } |
65 | } |
66 | |
67 | string ProtoDebugString( |
68 | const ::tensorflow::SerializedDType& msg) { |
69 | string s; |
70 | ::tensorflow::strings::ProtoTextOutput o(&s, false); |
71 | internal::AppendProtoDebugString(&o, msg); |
72 | o.CloseTopMessage(); |
73 | return s; |
74 | } |
75 | |
76 | string ProtoShortDebugString( |
77 | const ::tensorflow::SerializedDType& msg) { |
78 | string s; |
79 | ::tensorflow::strings::ProtoTextOutput o(&s, true); |
80 | internal::AppendProtoDebugString(&o, msg); |
81 | o.CloseTopMessage(); |
82 | return s; |
83 | } |
84 | |
85 | namespace internal { |
86 | |
87 | void AppendProtoDebugString( |
88 | ::tensorflow::strings::ProtoTextOutput* o, |
89 | const ::tensorflow::SerializedDType& msg) { |
90 | if (msg.datatype() != 0) { |
91 | const char* enum_name = ::tensorflow::EnumName_DataType(msg.datatype()); |
92 | if (enum_name[0]) { |
93 | o->AppendEnumName("datatype" , enum_name); |
94 | } else { |
95 | o->AppendNumeric("datatype" , msg.datatype()); |
96 | } |
97 | } |
98 | } |
99 | |
100 | } // namespace internal |
101 | |
102 | bool ProtoParseFromString( |
103 | const string& s, |
104 | ::tensorflow::SerializedDType* msg) { |
105 | msg->Clear(); |
106 | Scanner scanner(s); |
107 | if (!internal::ProtoParseFromScanner(&scanner, false, false, msg)) return false; |
108 | scanner.Eos(); |
109 | return scanner.GetResult(); |
110 | } |
111 | |
112 | namespace internal { |
113 | |
114 | bool ProtoParseFromScanner( |
115 | ::tensorflow::strings::Scanner* scanner, bool nested, bool close_curly, |
116 | ::tensorflow::SerializedDType* msg) { |
117 | std::vector<bool> has_seen(1, false); |
118 | while(true) { |
119 | ProtoSpaceAndComments(scanner); |
120 | if (nested && (scanner->Peek() == (close_curly ? '}' : '>'))) { |
121 | scanner->One(Scanner::ALL); |
122 | ProtoSpaceAndComments(scanner); |
123 | return true; |
124 | } |
125 | if (!nested && scanner->empty()) { return true; } |
126 | scanner->RestartCapture() |
127 | .Many(Scanner::LETTER_DIGIT_UNDERSCORE) |
128 | .StopCapture(); |
129 | StringPiece identifier; |
130 | if (!scanner->GetResult(nullptr, &identifier)) return false; |
131 | bool parsed_colon = false; |
132 | (void)parsed_colon; |
133 | ProtoSpaceAndComments(scanner); |
134 | if (scanner->Peek() == ':') { |
135 | parsed_colon = true; |
136 | scanner->One(Scanner::ALL); |
137 | ProtoSpaceAndComments(scanner); |
138 | } |
139 | if (identifier == "datatype" ) { |
140 | if (has_seen[0]) return false; |
141 | has_seen[0] = true; |
142 | StringPiece value; |
143 | if (!parsed_colon || !scanner->RestartCapture().Many(Scanner::LETTER_DIGIT_DASH_UNDERSCORE).GetResult(nullptr, &value)) return false; |
144 | if (value == "DT_INVALID" ) { |
145 | msg->set_datatype(::tensorflow::DT_INVALID); |
146 | } else if (value == "DT_FLOAT" ) { |
147 | msg->set_datatype(::tensorflow::DT_FLOAT); |
148 | } else if (value == "DT_DOUBLE" ) { |
149 | msg->set_datatype(::tensorflow::DT_DOUBLE); |
150 | } else if (value == "DT_INT32" ) { |
151 | msg->set_datatype(::tensorflow::DT_INT32); |
152 | } else if (value == "DT_UINT8" ) { |
153 | msg->set_datatype(::tensorflow::DT_UINT8); |
154 | } else if (value == "DT_INT16" ) { |
155 | msg->set_datatype(::tensorflow::DT_INT16); |
156 | } else if (value == "DT_INT8" ) { |
157 | msg->set_datatype(::tensorflow::DT_INT8); |
158 | } else if (value == "DT_STRING" ) { |
159 | msg->set_datatype(::tensorflow::DT_STRING); |
160 | } else if (value == "DT_COMPLEX64" ) { |
161 | msg->set_datatype(::tensorflow::DT_COMPLEX64); |
162 | } else if (value == "DT_INT64" ) { |
163 | msg->set_datatype(::tensorflow::DT_INT64); |
164 | } else if (value == "DT_BOOL" ) { |
165 | msg->set_datatype(::tensorflow::DT_BOOL); |
166 | } else if (value == "DT_QINT8" ) { |
167 | msg->set_datatype(::tensorflow::DT_QINT8); |
168 | } else if (value == "DT_QUINT8" ) { |
169 | msg->set_datatype(::tensorflow::DT_QUINT8); |
170 | } else if (value == "DT_QINT32" ) { |
171 | msg->set_datatype(::tensorflow::DT_QINT32); |
172 | } else if (value == "DT_BFLOAT16" ) { |
173 | msg->set_datatype(::tensorflow::DT_BFLOAT16); |
174 | } else if (value == "DT_QINT16" ) { |
175 | msg->set_datatype(::tensorflow::DT_QINT16); |
176 | } else if (value == "DT_QUINT16" ) { |
177 | msg->set_datatype(::tensorflow::DT_QUINT16); |
178 | } else if (value == "DT_UINT16" ) { |
179 | msg->set_datatype(::tensorflow::DT_UINT16); |
180 | } else if (value == "DT_COMPLEX128" ) { |
181 | msg->set_datatype(::tensorflow::DT_COMPLEX128); |
182 | } else if (value == "DT_HALF" ) { |
183 | msg->set_datatype(::tensorflow::DT_HALF); |
184 | } else if (value == "DT_RESOURCE" ) { |
185 | msg->set_datatype(::tensorflow::DT_RESOURCE); |
186 | } else if (value == "DT_VARIANT" ) { |
187 | msg->set_datatype(::tensorflow::DT_VARIANT); |
188 | } else if (value == "DT_UINT32" ) { |
189 | msg->set_datatype(::tensorflow::DT_UINT32); |
190 | } else if (value == "DT_UINT64" ) { |
191 | msg->set_datatype(::tensorflow::DT_UINT64); |
192 | } else if (value == "DT_FLOAT_REF" ) { |
193 | msg->set_datatype(::tensorflow::DT_FLOAT_REF); |
194 | } else if (value == "DT_DOUBLE_REF" ) { |
195 | msg->set_datatype(::tensorflow::DT_DOUBLE_REF); |
196 | } else if (value == "DT_INT32_REF" ) { |
197 | msg->set_datatype(::tensorflow::DT_INT32_REF); |
198 | } else if (value == "DT_UINT8_REF" ) { |
199 | msg->set_datatype(::tensorflow::DT_UINT8_REF); |
200 | } else if (value == "DT_INT16_REF" ) { |
201 | msg->set_datatype(::tensorflow::DT_INT16_REF); |
202 | } else if (value == "DT_INT8_REF" ) { |
203 | msg->set_datatype(::tensorflow::DT_INT8_REF); |
204 | } else if (value == "DT_STRING_REF" ) { |
205 | msg->set_datatype(::tensorflow::DT_STRING_REF); |
206 | } else if (value == "DT_COMPLEX64_REF" ) { |
207 | msg->set_datatype(::tensorflow::DT_COMPLEX64_REF); |
208 | } else if (value == "DT_INT64_REF" ) { |
209 | msg->set_datatype(::tensorflow::DT_INT64_REF); |
210 | } else if (value == "DT_BOOL_REF" ) { |
211 | msg->set_datatype(::tensorflow::DT_BOOL_REF); |
212 | } else if (value == "DT_QINT8_REF" ) { |
213 | msg->set_datatype(::tensorflow::DT_QINT8_REF); |
214 | } else if (value == "DT_QUINT8_REF" ) { |
215 | msg->set_datatype(::tensorflow::DT_QUINT8_REF); |
216 | } else if (value == "DT_QINT32_REF" ) { |
217 | msg->set_datatype(::tensorflow::DT_QINT32_REF); |
218 | } else if (value == "DT_BFLOAT16_REF" ) { |
219 | msg->set_datatype(::tensorflow::DT_BFLOAT16_REF); |
220 | } else if (value == "DT_QINT16_REF" ) { |
221 | msg->set_datatype(::tensorflow::DT_QINT16_REF); |
222 | } else if (value == "DT_QUINT16_REF" ) { |
223 | msg->set_datatype(::tensorflow::DT_QUINT16_REF); |
224 | } else if (value == "DT_UINT16_REF" ) { |
225 | msg->set_datatype(::tensorflow::DT_UINT16_REF); |
226 | } else if (value == "DT_COMPLEX128_REF" ) { |
227 | msg->set_datatype(::tensorflow::DT_COMPLEX128_REF); |
228 | } else if (value == "DT_HALF_REF" ) { |
229 | msg->set_datatype(::tensorflow::DT_HALF_REF); |
230 | } else if (value == "DT_RESOURCE_REF" ) { |
231 | msg->set_datatype(::tensorflow::DT_RESOURCE_REF); |
232 | } else if (value == "DT_VARIANT_REF" ) { |
233 | msg->set_datatype(::tensorflow::DT_VARIANT_REF); |
234 | } else if (value == "DT_UINT32_REF" ) { |
235 | msg->set_datatype(::tensorflow::DT_UINT32_REF); |
236 | } else if (value == "DT_UINT64_REF" ) { |
237 | msg->set_datatype(::tensorflow::DT_UINT64_REF); |
238 | } else { |
239 | int32 int_value; |
240 | if (strings::SafeStringToNumeric(value, &int_value)) { |
241 | msg->set_datatype(static_cast<::tensorflow::DataType>(int_value)); |
242 | } else { |
243 | return false; |
244 | } |
245 | } |
246 | } |
247 | } |
248 | } |
249 | |
250 | } // namespace internal |
251 | |
252 | } // namespace tensorflow |
253 | |