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

Method Convert

tensorflow/core/graph/graph_constructor.cc:1099–1277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1097}
1098
1099Status GraphConstructor::Convert() {
1100 // Import functions before adding nodes, since imported nodes may refer to
1101 // functions
1102 if (library()) {
1103 // TODO(b/135705010): Add rvalue overloads into the function library, to
1104 // avoid unnecessarily copying `*library()` here.
1105 TF_RETURN_IF_ERROR(g_->AddFunctionLibrary(*library()));
1106 }
1107
1108 std::vector<InputInfo> inputs;
1109 int processed = 0;
1110
1111 std::vector<bool> input_already_exists;
1112
1113 // Process the NodeDefs in topological order.
1114 // (InitFromEdges() sets this up by filling in ready_ with nodes that have no
1115 // inputs, pending_counts_ with the number of inputs for each node and
1116 // outputs_ with the outputs of each node).
1117 while (!ready_.empty()) {
1118 int o = *ready_.begin();
1119 ready_.erase(ready_.begin());
1120 ++processed;
1121 inputs.clear();
1122 bool has_data_back_edge = false;
1123
1124 NodeDef node_def = consume_node_def(o);
1125
1126 // input_already_exists[i] is true iff the i-th input of the node we're
1127 // importing refers to a preexisting node in g_ (i.e. input[i] existed prior
1128 // to importing node_defs_). Conversely, input_already_exists[i] is false
1129 // iff the input refers to a node in node_defs_.
1130 input_already_exists.clear();
1131 input_already_exists.resize(node_def.input_size(), false);
1132
1133 ssize_t string_intern_table_index = -1;
1134
1135 if (opts_.importing) {
1136 // Intern the original node name, so that we can use a StringPiece of the
1137 // name to index gdef_nodes_.
1138 string_intern_table_index = string_intern_table_.size();
1139 string_intern_table_.push_back(node_def.name());
1140
1141 if (opts_.skip_mapped_nodes) {
1142 bool is_node_mapped = false;
1143 TF_RETURN_IF_ERROR(IsNodeFullyMapped(node_def, &is_node_mapped));
1144 if (is_node_mapped) {
1145 // Skip this node after updating pending_count_ for outputs
1146 UpdatePendingCountAndReady(o, IsNextIteration(node_def));
1147 continue;
1148 }
1149 }
1150
1151 if (!opts_.input_map.empty()) {
1152 // Note that input_already_exists can shrink here
1153 RemapNodeDefInputs(&node_def, &input_already_exists);
1154 }
1155 if (!opts_.control_dependencies.empty()) {
1156 // Note that input_already_exists can grow here

Callers

nothing calls this directly

Calls 15

ParseTensorNameFunction · 0.85
InvalidArgumentFunction · 0.85
MakeNodeFunction · 0.85
sortFunction · 0.85
ValidateShapeFunction · 0.85
SummarizeNodeDefFunction · 0.85
IsNextIterationMethod · 0.80
IsNextIterationFunction · 0.70
IsMergeFunction · 0.70
nameMethod · 0.65
uniqueFunction · 0.50
AddFunctionLibraryMethod · 0.45

Tested by

no test coverage detected