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

Method RemoveAllFanins

tensorflow/core/grappler/mutable_graph_view.cc:1204–1234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1202}
1203
1204Status MutableGraphView::RemoveAllFanins(absl::string_view node_name,
1205 bool keep_controlling_fanins) {
1206 NodeDef* node = GetNode(node_name);
1207 if (node == nullptr) {
1208 string params =
1209 absl::Substitute("node_name='$0', keep_controlling_fanins=$1",
1210 node_name, keep_controlling_fanins);
1211 return MutationError("RemoveAllFanins", params,
1212 NodeMissingErrorMsg(node_name));
1213 }
1214
1215 if (node->input().empty()) {
1216 return Status::OK();
1217 }
1218
1219 const int num_regular_fanins =
1220 NumFanins(*node, /*include_controlling_nodes=*/false);
1221 RemoveFaninsInternal(node, keep_controlling_fanins);
1222 if (keep_controlling_fanins) {
1223 if (num_regular_fanins == 0) {
1224 return Status::OK();
1225 } else if (num_regular_fanins < node->input_size()) {
1226 node->mutable_input()->DeleteSubrange(0, num_regular_fanins);
1227 } else {
1228 node->clear_input();
1229 }
1230 } else {
1231 node->clear_input();
1232 }
1233 return Status::OK();
1234}
1235
1236Status MutableGraphView::UpdateFanin(absl::string_view node_name,
1237 const TensorId& from_fanin,

Callers 1

TestRemoveAllFaninsFunction · 0.80

Calls 6

MutationErrorFunction · 0.85
NodeMissingErrorMsgFunction · 0.85
emptyMethod · 0.45
inputMethod · 0.45
input_sizeMethod · 0.45
mutable_inputMethod · 0.45

Tested by 1

TestRemoveAllFaninsFunction · 0.64