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

Function CanonicalizeNode

tensorflow/core/grappler/utils/canonicalizer.cc:27–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace grappler {
26
27void CanonicalizeNode(NodeDef* node) {
28 if (node->input_size() < 2) return;
29 // Partition control and regular inputs.
30 int index = 0;
31 for (; index < node->input_size(); ++index) {
32 if (IsControlInput(node->input(index))) {
33 break;
34 }
35 }
36 auto* input = node->mutable_input();
37 // Maybe sort regular inputs.
38 if (IsCommutative(*node) && index > 0) {
39 std::sort(input->begin(), input->begin() + index);
40 }
41 // Sort and dedup control inputs.
42 if (index < node->input_size()) {
43 std::sort(input->begin() + index, input->end());
44 input->erase(std::unique(input->begin() + index, input->end()),
45 input->end());
46 }
47}
48
49void CanonicalizeGraph(GraphDef* graph) {
50 for (int i = 0; i < graph->node_size(); ++i) {

Callers 3

CanonicalizeGraphFunction · 0.85
TESTFunction · 0.85
DedupComputationsMethod · 0.85

Calls 9

IsControlInputFunction · 0.85
sortFunction · 0.85
uniqueFunction · 0.50
input_sizeMethod · 0.45
inputMethod · 0.45
mutable_inputMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by 1

TESTFunction · 0.68