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

Function TEST

tensorflow/compiler/jit/async_io_conversion_pass_test.cc:163–208  ·  view source on GitHub ↗

Tests that AsyncIoConversionPass does not replace either Resource or Const output edges.

Source from the content-addressed store, hash-verified

161// Tests that AsyncIoConversionPass does not replace either Resource
162// or Const output edges.
163TEST(AsyncIoConversionTest, ResourceAndConstRetval) {
164 const string cluster_name = "cluster_var_and_const";
165
166 auto graph = absl::make_unique<Graph>(OpRegistry::Global());
167 FunctionDefLibrary fdef_lib;
168 FunctionLibraryDefinition flib_def(OpRegistry::Global(), fdef_lib);
169 {
170 GraphDefBuilder builder(GraphDefBuilder::kFailImmediately, &flib_def);
171 Node* res_in =
172 ops::SourceOp("VarHandleOp", builder.opts()
173 .WithName("varhandle")
174 .WithAttr("dtype", DT_FLOAT)
175 .WithAttr("shape", TensorShape({})));
176 Node* const_in =
177 ops::SourceOp("Const", builder.opts()
178 .WithName("")
179 .WithAttr("dtype", DT_FLOAT)
180 .WithAttr("value", Tensor())
181 .WithAttr(kXlaClusterAttr, cluster_name));
182 Node* identity0 = ops::UnaryOp(
183 "Identity", res_in, builder.opts()
184 .WithName("identity0_in_cluster")
185 .WithDevice(kTestDeviceName)
186 .WithAttr("T", DT_RESOURCE)
187 .WithAttr(kXlaClusterAttr, cluster_name));
188 Node* identity1 = ops::UnaryOp("Identity", identity0,
189 builder.opts()
190 .WithName("identity1_outside_cluster")
191 .WithDevice(kTestDeviceName)
192 .WithAttr("T", DT_RESOURCE));
193 Node* identity2 = ops::UnaryOp("Identity", const_in,
194 builder.opts()
195 .WithName("identity2_outside_cluster")
196 .WithDevice(kTestDeviceName)
197 .WithAttr("T", DT_FLOAT));
198
199 TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get()));
200 }
201
202 TF_ASSERT_OK(ConvertToAsyncOut(&graph, &flib_def));
203
204 // Verify that no AsyncOut is inserted.
205 for (const Node* n : graph->op_nodes()) {
206 EXPECT_TRUE(!absl::StartsWith(n->type_string(), "_XlaAsyncOut"));
207 }
208}
209
210} // namespace
211} // namespace tensorflow

Calls 12

SourceOpFunction · 0.85
GraphDefBuilderToGraphFunction · 0.85
ConvertToAsyncOutFunction · 0.85
StartsWithFunction · 0.85
WithAttrMethod · 0.80
op_nodesMethod · 0.80
TensorShapeClass · 0.50
TensorClass · 0.50
UnaryOpClass · 0.50
WithNameMethod · 0.45
WithDeviceMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected