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

Function TEST

tensorflow/compiler/jit/cluster_scoping_pass_test.cc:85–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85TEST(XlaCompilationTest, StagePipelinePreserved) {
86 std::unique_ptr<Graph> graph(new Graph(OpRegistry::Global()));
87 {
88 // Graph:
89 // b
90 // |
91 // v
92 // a -> add0 (ClusterX) -> relu0 (ClusterX) -> stage
93 //
94 // b
95 // |
96 // v
97 // unstage -> add1 (ClusterY) -> relu1 (ClusterY)
98 GraphDefBuilder builder(GraphDefBuilder::kFailImmediately);
99 Node* a = ops::SourceOp("Const", builder.opts()
100 .WithName("a")
101 .WithAttr("dtype", DT_FLOAT)
102 .WithAttr("value", Tensor()));
103 Node* b = ops::SourceOp("Const", builder.opts()
104 .WithName("b")
105 .WithAttr("dtype", DT_FLOAT)
106 .WithAttr("value", Tensor()));
107 Node* unstage = ops::SourceOp(
108 "Unstage",
109 builder.opts().WithName("unstage").WithAttr("dtypes", {DT_FLOAT}));
110
111 Node* add0 = ops::BinaryOp("Add", a, b, builder.opts().WithName("add0"));
112 Node* add1 =
113 ops::BinaryOp("Add", unstage, b, builder.opts().WithName("add1"));
114 Node* relu0 = ops::UnaryOp("Relu", add0, builder.opts().WithName("relu0"));
115 ops::UnaryOp("Relu", add1, builder.opts().WithName("relu1"));
116 BuildStageNode(builder, "stage", {DT_FLOAT}, {relu0});
117
118 TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get()));
119 }
120
121 TF_ASSERT_OK(ClusterScoping(&graph));
122
123 auto scopes = GetXlaInternalScopes(*graph);
124 EXPECT_NE(scopes["add0"], scopes["add1"]);
125 EXPECT_EQ(scopes["add0"], scopes["relu0"]);
126 EXPECT_EQ(scopes["add1"], scopes["relu1"]);
127}
128
129TEST(XlaCompilationTest, StagePipelinePreservedAndInitialScopesRespected) {
130 std::unique_ptr<Graph> graph(new Graph(OpRegistry::Global()));

Callers

nothing calls this directly

Calls 11

SourceOpFunction · 0.85
BuildStageNodeFunction · 0.85
GraphDefBuilderToGraphFunction · 0.85
ClusterScopingFunction · 0.85
GetXlaInternalScopesFunction · 0.85
WithAttrMethod · 0.80
TensorClass · 0.50
BinaryOpClass · 0.50
UnaryOpClass · 0.50
WithNameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected