MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetArrayLabel

Function GetArrayLabel

tensorflow/lite/toco/dump_graphviz.cc:248–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248string GetArrayLabel(const Model& model, const string& array_id) {
249 string html;
250
251 // Use HTML-like labels (http://www.graphviz.org/doc/info/shapes.html#html)
252 html += "<";
253
254 // Begin Table
255 html += R"CODE(<FONT POINT-SIZE="10" FACE="Courier">)CODE";
256 html += R"CODE(<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0">)CODE";
257
258 auto& array = model.GetArray(array_id);
259 if (array.buffer) {
260 // "cylinder" shapes require some extra head room.
261 html += R"CODE(<TR><TD COLSPAN="2"> </TD></TR>)CODE";
262 }
263
264 // "Primary" name of array (last non-slash delimited group of characters).
265 html += R"CODE(<TR><TD COLSPAN="2" ALIGN="CENTER">)CODE";
266 html += R"CODE(<FONT POINT-SIZE="16" FACE="Helvetica"><I>)CODE";
267 AppendF(&html, R"CODE(%s)CODE",
268 std::vector<string>(absl::StrSplit(array_id, '/')).back());
269 html += R"CODE(</I></FONT>)CODE";
270 html += "</TD></TR>";
271
272 // Array data type and dimensions
273 html += R"CODE(<TR><TD COLSPAN="2" ALIGN="CENTER">)CODE";
274 html += R"CODE(<FONT POINT-SIZE="14" FACE="Courier"><B>)CODE";
275 // Type
276 html += ArrayDataTypeName(array.data_type);
277 // Shape
278 if (array.has_shape()) {
279 auto& array_shape = array.shape();
280 html += "[";
281 for (int dim = 0; dim < array_shape.dimensions_count(); dim++) {
282 AppendF(&html, "%d", array_shape.dims(dim));
283 if (dim + 1 < array_shape.dimensions_count()) {
284 html += kUnicodeMult;
285 }
286 }
287 html += "]";
288 }
289
290 // Small buffer sample
291 int buffer_size = 0;
292 if (array.buffer) {
293 buffer_size = RequiredBufferSizeForShape(array.shape());
294 }
295 if ((buffer_size > 0) && (buffer_size <= 4)) {
296 html += " = ";
297 if (array.shape().dimensions_count() > 0) {
298 html += "{";
299 }
300 for (int i = 0; i < buffer_size; i++) {
301 AppendArrayVal(&html, array, i);
302 if (i + 1 < buffer_size) {
303 html += ", ";
304 }
305 }

Callers 1

DumpArrayFunction · 0.85

Calls 11

AppendFFunction · 0.85
ArrayDataTypeNameFunction · 0.85
AppendArrayValFunction · 0.85
StringFFunction · 0.85
AttributesToHtmlFunction · 0.85
has_shapeMethod · 0.80
dimensions_countMethod · 0.80
backMethod · 0.45
shapeMethod · 0.45
dimsMethod · 0.45

Tested by

no test coverage detected