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

Function CheckLoopConstruction

tensorflow/core/graph/graph_partition_test.cc:120–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void CheckLoopConstruction(const GraphDef& graph_def) {
121 std::unordered_map<string, GraphDef> partitions;
122 Partition(graph_def, &partitions);
123 for (const auto& kv : partitions) {
124 const GraphDef& gdef = kv.second;
125 bool has_control_enter = false;
126 bool has_control_merge = false;
127 bool has_control_switch = false;
128 bool has_control_next = false;
129 for (const NodeDef& ndef : gdef.node()) {
130 // _recvs must have a control input
131 if (ndef.op() == "_Recv") {
132 bool has_control = false;
133 for (const string& input_name : ndef.input()) {
134 if (absl::StartsWith(input_name, "^")) {
135 has_control = true;
136 break;
137 }
138 }
139 EXPECT_TRUE(has_control);
140 }
141 // Must have a control loop
142 if (absl::StartsWith(ndef.name(), "_cloop")) {
143 if (ndef.op() == "Enter") {
144 has_control_enter = true;
145 }
146 if (ndef.op() == "Merge") {
147 has_control_merge = true;
148 }
149 if (ndef.op() == "Switch") {
150 has_control_switch = true;
151 }
152 if (ndef.op() == "NextIteration") {
153 has_control_next = true;
154 }
155 }
156 }
157 EXPECT_TRUE(has_control_enter);
158 EXPECT_TRUE(has_control_merge);
159 EXPECT_TRUE(has_control_switch);
160 EXPECT_TRUE(has_control_next);
161 }
162}
163
164REGISTER_OP("FloatInput")
165 .Output("o: float")

Callers 1

TEST_FFunction · 0.85

Calls 6

StartsWithFunction · 0.85
PartitionFunction · 0.70
nameMethod · 0.65
nodeMethod · 0.45
opMethod · 0.45
inputMethod · 0.45

Tested by

no test coverage detected