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

Function ProcessTargetEdges

tensorflow/core/graph/quantize_training.cc:568–594  ·  view source on GitHub ↗

Insert conversion op, connect it to the graph and remove the old edge.

Source from the content-addressed store, hash-verified

566
567// Insert conversion op, connect it to the graph and remove the old edge.
568Status ProcessTargetEdges(Graph* graph, const string& quant_op_type,
569 const std::vector<EdgeToConvert>& target_edges) {
570 // Remember previously converted ops to avoid duplicated conversion on the
571 // same input.
572 std::unordered_map<string, Node*, StringPieceHasher> name_index;
573 std::vector<Node*> added_variables;
574 for (const EdgeToConvert edge : target_edges) {
575 Node* convert_node;
576 string name_prefix = edge.edge->src()->name();
577
578 auto iter = name_index.find(name_prefix);
579 if (iter == name_index.end()) {
580 TF_RETURN_IF_ERROR(MakeQuantizeOp(graph, name_prefix, quant_op_type, edge,
581 &added_variables, &convert_node));
582 name_index[name_prefix] = convert_node;
583 } else {
584 convert_node = iter->second;
585 }
586
587 graph->AddEdge(convert_node, 0, edge.edge->dst(), edge.edge->dst_input());
588 graph->RemoveEdge(edge.edge);
589 }
590
591 TF_RETURN_IF_ERROR(AddSaveAndRestore(graph, added_variables));
592
593 return Status::OK();
594}
595
596} // namespace
597

Callers 1

DoQuantizeTrainingFunction · 0.85

Calls 10

MakeQuantizeOpFunction · 0.85
AddSaveAndRestoreFunction · 0.85
nameMethod · 0.65
srcMethod · 0.45
findMethod · 0.45
endMethod · 0.45
AddEdgeMethod · 0.45
dstMethod · 0.45
dst_inputMethod · 0.45
RemoveEdgeMethod · 0.45

Tested by

no test coverage detected