aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/hlo_dataflow_analysis_test.cc
diff options
context:
space:
mode:
authorGravatar Mark Heffernan <meheff@google.com>2017-06-09 11:03:02 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-06-09 11:06:19 -0700
commitc60899ae706357383826ea05cf380462eb3fe2ad (patch)
tree3c5b4345adcb24840bd5fae3e571661cc69d7673 /tensorflow/compiler/xla/service/hlo_dataflow_analysis_test.cc
parent7b22e9685c0157da9e786f7ced2f7a027e3015c6 (diff)
[XLA] Add HLO alias analysis.
Add HloAliasAnalysis which identifies aliasing of buffers in the HLO graph. This analysis is module-scoped and will eventually replace the computation-scoped TuplePointsToAnalysis. Currently the analysis is unused, but later CLs will incrementally replace TuplePointsToAnalysis with HloAliasAnalysis (or potentially HloDataflowAnalysis). This CL also includes a small change to HloDataflowAnalysis. When ssa_form is true, only while instructions (which update inplace) define phi values. Previously, subcomputations called from multiple kCall instructions would also define phi values. Effectively this is an inconsequential change because we always flatten the callgraph eliminating multiple callsites for the same subcomputation. PiperOrigin-RevId: 158537805
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_dataflow_analysis_test.cc')
-rw-r--r--tensorflow/compiler/xla/service/hlo_dataflow_analysis_test.cc76
1 files changed, 33 insertions, 43 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_dataflow_analysis_test.cc b/tensorflow/compiler/xla/service/hlo_dataflow_analysis_test.cc
index 0c3208f788..21344af5f2 100644
--- a/tensorflow/compiler/xla/service/hlo_dataflow_analysis_test.cc
+++ b/tensorflow/compiler/xla/service/hlo_dataflow_analysis_test.cc
@@ -358,23 +358,13 @@ TEST_P(HloDataflowAnalysisTest, ComputationCalledTwiceWithDifferentArguments) {
EXPECT_FALSE(analysis.ValueIsDefinedAt(call1));
EXPECT_FALSE(analysis.ValueIsDefinedAt(call2));
- if (ssa_form) {
- // Argument 0 has different values at the two calls, and argument 1 has the
- // same value, so only argument 0 should have a phi value.
- EXPECT_TRUE(analysis.ValueIsDefinedAt(subparam0));
- EXPECT_TRUE(analysis.GetValueDefinedAt(subparam0).is_phi());
-
- EXPECT_FALSE(analysis.ValueIsDefinedAt(subparam1));
- } else {
- EXPECT_FALSE(analysis.ValueIsDefinedAt(subparam0));
- EXPECT_FALSE(analysis.ValueIsDefinedAt(subparam1));
+ EXPECT_FALSE(analysis.ValueIsDefinedAt(subparam0));
- EXPECT_THAT(HloValuesAt(subparam0),
- UnorderedElementsAre(analysis.GetValueDefinedAt(constant1),
- analysis.GetValueDefinedAt(add)));
- EXPECT_THAT(HloValuesAt(subparam1),
- UnorderedElementsAre(analysis.GetValueDefinedAt(constant2)));
- }
+ EXPECT_THAT(HloValuesAt(subparam0),
+ UnorderedElementsAre(analysis.GetValueDefinedAt(constant1),
+ analysis.GetValueDefinedAt(add)));
+ EXPECT_THAT(HloValuesAt(subparam1),
+ UnorderedElementsAre(analysis.GetValueDefinedAt(constant2)));
EXPECT_TRUE(analysis.GetValueDefinedAt(add).live_out_of_module());
}
@@ -889,34 +879,34 @@ TEST_P(HloDataflowAnalysisTest, TupleSelect) {
EXPECT_TRUE(analysis.ValueIsDefinedAt(select34));
EXPECT_TRUE(analysis.ValueIsDefinedAt(select1234));
- EXPECT_FALSE(analysis.ValueIsDefinedAt(select11, /*index=*/{0}));
- EXPECT_FALSE(analysis.ValueIsDefinedAt(select12, /*index=*/{0}));
- EXPECT_FALSE(analysis.ValueIsDefinedAt(select34, /*index=*/{0}));
- EXPECT_FALSE(analysis.ValueIsDefinedAt(select1234, /*index=*/{0}));
-
- EXPECT_THAT(HloValuesAt(select11, /*index=*/{0}),
- UnorderedElementsAre(analysis.GetValueDefinedAt(constant1)));
- EXPECT_THAT(HloValuesAt(select12, /*index=*/{0}),
- UnorderedElementsAre(analysis.GetValueDefinedAt(constant1),
- analysis.GetValueDefinedAt(constant2)));
- EXPECT_THAT(HloValuesAt(select34, /*index=*/{0}),
- UnorderedElementsAre(analysis.GetValueDefinedAt(constant3),
- analysis.GetValueDefinedAt(constant4)));
- EXPECT_THAT(HloValuesAt(select1234, /*index=*/{0}),
- UnorderedElementsAre(analysis.GetValueDefinedAt(constant1),
- analysis.GetValueDefinedAt(constant2),
- analysis.GetValueDefinedAt(constant3),
- analysis.GetValueDefinedAt(constant4)));
+ EXPECT_FALSE(analysis.ValueIsDefinedAt(select11, /*index=*/{0}));
+ EXPECT_FALSE(analysis.ValueIsDefinedAt(select12, /*index=*/{0}));
+ EXPECT_FALSE(analysis.ValueIsDefinedAt(select34, /*index=*/{0}));
+ EXPECT_FALSE(analysis.ValueIsDefinedAt(select1234, /*index=*/{0}));
+
+ EXPECT_THAT(HloValuesAt(select11, /*index=*/{0}),
+ UnorderedElementsAre(analysis.GetValueDefinedAt(constant1)));
+ EXPECT_THAT(HloValuesAt(select12, /*index=*/{0}),
+ UnorderedElementsAre(analysis.GetValueDefinedAt(constant1),
+ analysis.GetValueDefinedAt(constant2)));
+ EXPECT_THAT(HloValuesAt(select34, /*index=*/{0}),
+ UnorderedElementsAre(analysis.GetValueDefinedAt(constant3),
+ analysis.GetValueDefinedAt(constant4)));
+ EXPECT_THAT(HloValuesAt(select1234, /*index=*/{0}),
+ UnorderedElementsAre(analysis.GetValueDefinedAt(constant1),
+ analysis.GetValueDefinedAt(constant2),
+ analysis.GetValueDefinedAt(constant3),
+ analysis.GetValueDefinedAt(constant4)));
- EXPECT_THAT(
- analysis.GetValueDefinedAt(constant1).uses(),
- UnorderedElementsAre(HloUse{tuple1, 0, {}}, HloUse{select11, 1, {0}},
- HloUse{select11, 2, {0}}, HloUse{select12, 1, {0}},
- HloUse{select1234, 1, {0}}));
- EXPECT_THAT(
- analysis.GetValueDefinedAt(constant2).uses(),
- UnorderedElementsAre(HloUse{tuple2, 0, {}}, HloUse{select12, 2, {0}},
- HloUse{select1234, 1, {0}}));
+ EXPECT_THAT(
+ analysis.GetValueDefinedAt(constant1).uses(),
+ UnorderedElementsAre(HloUse{tuple1, 0, {}}, HloUse{select11, 1, {0}},
+ HloUse{select11, 2, {0}}, HloUse{select12, 1, {0}},
+ HloUse{select1234, 1, {0}}));
+ EXPECT_THAT(
+ analysis.GetValueDefinedAt(constant2).uses(),
+ UnorderedElementsAre(HloUse{tuple2, 0, {}}, HloUse{select12, 2, {0}},
+ HloUse{select1234, 1, {0}}));
}
TEST_P(HloDataflowAnalysisTest, NestedTupleSelect) {