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

Method CheckFaninsInternal

tensorflow/core/grappler/utils/graph_view.cc:496–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494}
495
496Status MutableGraphView::CheckFaninsInternal(
497 std::vector<std::vector<TensorId>>* fanins) {
498 const int num_nodes = nodes_.size();
499 fanins->reserve(num_nodes);
500 for (int i = 0; i < num_nodes; ++i) {
501 bool has_observed_control = false;
502 const NodeDef* node = nodes_[i].node();
503 const string& node_name = node->name();
504 std::vector<TensorId> node_fanins;
505 node_fanins.reserve(node->input_size());
506 for (const string& input : node->input()) {
507 TensorId fanin_id = ParseTensorName(input);
508 if (fanin_id.node() == node_name) {
509 return errors::InvalidArgument(kMutableGraphViewError, "node '",
510 node_name, "' has self cycle fanin '",
511 input, "'.");
512 }
513 bool is_control = IsTensorIdControl(fanin_id);
514 if (!is_control && has_observed_control) {
515 return errors::InvalidArgument(kMutableGraphViewError, "node '",
516 node_name, "' has regular fanin '",
517 input, "' after controlling fanins.");
518 }
519 if (!node_index_by_name_.contains(fanin_id.node())) {
520 return errors::InvalidArgument(kMutableGraphViewError, "node '",
521 node_name, "' has missing fanin '",
522 input, "'.");
523 }
524 if (is_control) {
525 has_observed_control = true;
526 }
527 node_fanins.push_back(std::move(fanin_id));
528 }
529 fanins->push_back(std::move(node_fanins));
530 }
531 return Status::OK();
532}
533
534void MutableGraphView::AddFaninsInternal(
535 std::vector<std::vector<TensorId>>* fanins) {

Callers

nothing calls this directly

Calls 11

ParseTensorNameFunction · 0.85
InvalidArgumentFunction · 0.85
IsTensorIdControlFunction · 0.85
containsMethod · 0.80
nameMethod · 0.65
sizeMethod · 0.45
reserveMethod · 0.45
nodeMethod · 0.45
input_sizeMethod · 0.45
inputMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected