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

Function LogDumpGraphDef

tensorflow/lite/toco/tensorflow_util.cc:40–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38using tensorflow::GraphDef;
39
40void LogDumpGraphDef(int log_level, const string& message,
41 const GraphDef& tf_graph) {
42 if (!VLOG_IS_ON(log_level)) {
43 return;
44 }
45 std::set<string> ops;
46 for (const auto& node : tf_graph.node()) {
47 ops.insert(node.op());
48 }
49 string dump;
50 toco::port::AppendF(&dump, R"MSG(
51BEGIN DUMP OF TENSORFLOW GRAPHDEF (%s)
52There are %d nodes.
53There are %zu different op types:
54)MSG",
55 message, tf_graph.node_size(), ops.size());
56 for (const auto& op : ops) {
57 toco::port::AppendF(&dump, " %s\n", op);
58 }
59 dump.append(R"MSG(
60PROTO DUMP
61)MSG");
62 for (const auto& node : tf_graph.node()) {
63 toco::port::AppendF(&dump, R"MSG(
64BEGIN NODE: name = %s
65 op = %s
66 inputs = [
67)MSG",
68 node.name(), node.op());
69 for (const auto& input : node.input()) {
70 toco::port::AppendF(&dump, " %s\n", input);
71 }
72 dump.append(" ]\n");
73 for (const auto& attr : node.attr()) {
74 toco::port::AppendF(&dump, " ATTR: name = %s\n", attr.first);
75 if (attr.second.value_case() == AttrValue::kFunc) {
76 dump.append(" func\n");
77 } else if (attr.second.value_case() == AttrValue::kPlaceholder) {
78 toco::port::AppendF(&dump, " placeholder: %s\n",
79 attr.second.placeholder());
80 } else if (attr.second.value_case() == AttrValue::kS) {
81 dump.append(" string:\n");
82 dump.append(R"MSG(
83 BEGIN EMBEDDED STRING
84)MSG");
85 const auto& lines = absl::StrSplit(attr.second.s(), '\n');
86 for (const auto& line : lines) {
87 toco::port::AppendF(&dump, " %s\n", line);
88 }
89 dump.append(R"MSG(
90 END EMBEDDED STRING
91)MSG");
92 } else if (attr.second.value_case() == AttrValue::kI) {
93 toco::port::AppendF(&dump, " int: %lld\n", attr.second.i());
94 } else if (attr.second.value_case() == AttrValue::kF) {
95 toco::port::AppendF(&dump, " float: %g\n", attr.second.f());
96 } else if (attr.second.value_case() == AttrValue::kB) {
97 toco::port::AppendF(&dump, " bool: %s\n",

Callers 2

ImportTensorFlowGraphDefFunction · 0.85
ExportTensorFlowGraphDefFunction · 0.85

Calls 15

AppendFFunction · 0.85
attrMethod · 0.80
CopyToBufferFunction · 0.70
nameMethod · 0.65
typeMethod · 0.65
nodeMethod · 0.45
insertMethod · 0.45
opMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45
inputMethod · 0.45
placeholderMethod · 0.45

Tested by

no test coverage detected