aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/call_graph_test.cc
diff options
context:
space:
mode:
authorGravatar Mark Heffernan <meheff@google.com>2017-06-19 18:38:20 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-06-19 18:41:40 -0700
commit5b6a203c5c759656b2b7018271219916ddd85cb6 (patch)
treee4ba01c8a30d2066ee7f05a147638e5d0cbe246b /tensorflow/compiler/xla/service/call_graph_test.cc
parenta36488d812780e78f869a3eb2b692cf3c236f1cc (diff)
[XLA] Add live range interference querying to dataflow analysis.
Add method MayInterfere to HloDataflowAnalysis which returns whether the live ranges of two values interfere. This will replace buffer_liveness.cc. The cl includes a few related changes: (1) HloOrdering: Apply an order to the condition and body computations. Specifically, for the purposes of HLO ordering the condition is ordered before the body. This ensures that the live ranges of values in the condition do not interfere with the live ranges in the body. (2) Add a Dominates method to CallGraph for determining whether a computation dominates another in the call graph. (3) Tightened the definition of "use" in the dataflow analysis. Now an instruction which passes through a value without reading it is no longer considered a use of the value. This new definition is reflected in the HloUse objects returned by HloValue::uses(). PiperOrigin-RevId: 159509724
Diffstat (limited to 'tensorflow/compiler/xla/service/call_graph_test.cc')
-rw-r--r--tensorflow/compiler/xla/service/call_graph_test.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/call_graph_test.cc b/tensorflow/compiler/xla/service/call_graph_test.cc
index bbf67c9803..3c22871b3b 100644
--- a/tensorflow/compiler/xla/service/call_graph_test.cc
+++ b/tensorflow/compiler/xla/service/call_graph_test.cc
@@ -314,6 +314,37 @@ TEST_F(CallGraphTest, ComplexGraph) {
EXPECT_LT(index_of(cond_computation), index_of(a_computation));
EXPECT_LT(index_of(c_computation), index_of(b_computation));
EXPECT_LT(index_of(b_computation), index_of(a_computation));
+
+ // Verify dominance relations between computation in the graph.
+
+ // Entry dominates everybody, and is dominated by no one except itself.
+ EXPECT_TRUE(call_graph->Dominates(entry_computation, entry_computation));
+ EXPECT_TRUE(call_graph->Dominates(entry_computation, a_computation));
+ EXPECT_TRUE(call_graph->Dominates(entry_computation, b_computation));
+ EXPECT_TRUE(call_graph->Dominates(entry_computation, c_computation));
+ EXPECT_TRUE(call_graph->Dominates(entry_computation, cond_computation));
+ EXPECT_FALSE(call_graph->Dominates(a_computation, entry_computation));
+ EXPECT_FALSE(call_graph->Dominates(b_computation, entry_computation));
+ EXPECT_FALSE(call_graph->Dominates(c_computation, entry_computation));
+ EXPECT_FALSE(call_graph->Dominates(cond_computation, entry_computation));
+
+ // 'a' only dominates 'b' and 'c'.
+ EXPECT_TRUE(call_graph->Dominates(a_computation, a_computation));
+ EXPECT_TRUE(call_graph->Dominates(a_computation, b_computation));
+ EXPECT_TRUE(call_graph->Dominates(a_computation, c_computation));
+ EXPECT_FALSE(call_graph->Dominates(b_computation, a_computation));
+ EXPECT_FALSE(call_graph->Dominates(c_computation, a_computation));
+ EXPECT_FALSE(call_graph->Dominates(a_computation, cond_computation));
+
+ EXPECT_TRUE(call_graph->Dominates(b_computation, b_computation));
+ EXPECT_FALSE(call_graph->Dominates(b_computation, c_computation));
+ EXPECT_FALSE(call_graph->Dominates(b_computation, cond_computation));
+
+ EXPECT_TRUE(call_graph->Dominates(c_computation, c_computation));
+ EXPECT_FALSE(call_graph->Dominates(c_computation, cond_computation));
+ EXPECT_FALSE(call_graph->Dominates(cond_computation, c_computation));
+
+ EXPECT_TRUE(call_graph->Dominates(cond_computation, cond_computation));
}
TEST_F(CallGraphTest, VisitSingletonComputation) {