| 83 | } |
| 84 | |
| 85 | TEST(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 | |
| 129 | TEST(XlaCompilationTest, StagePipelinePreservedAndInitialScopesRespected) { |
| 130 | std::unique_ptr<Graph> graph(new Graph(OpRegistry::Global())); |
nothing calls this directly
no test coverage detected