aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-01-10 14:52:27 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-01-10 15:03:36 -0800
commit4c24ab2d0651b048d81c4743b73ac92b5c39d8cc (patch)
tree673b9b0e957f1a100196172904c34bd74a447e3b /tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
parent69f231135304799f581d34df37d72cdc07fc8f58 (diff)
[TF:XLA] Fix infinite loop in HLO data flow analysis.
Merge input values at phi nodes correctly: If a phi operand is the phi itself, and the other operands are all the same, then the phi node is redundant. PiperOrigin-RevId: 181521522
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc')
-rw-r--r--tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc b/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
index 80d89d851e..d25fc5d741 100644
--- a/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
+++ b/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
@@ -154,7 +154,11 @@ bool HloDataflowAnalysis::Phi(
tensorflow::gtl::ArraySlice<const InstructionValueSet*> inputs) {
CHECK(ssa_form_);
VLOG(4) << "Phi(" << instruction->name() << ")";
-
+ VLOG(5) << "instruction value set = "
+ << GetInstructionValueSet(instruction).ToString();
+ for (const InstructionValueSet* input : inputs) {
+ VLOG(5) << "input value set = " << input->ToString();
+ }
for (const InstructionValueSet* input : inputs) {
DCHECK(ShapeUtil::Compatible(instruction->shape(), input->shape()));
}
@@ -171,9 +175,14 @@ bool HloDataflowAnalysis::Phi(
value_set.values().size() == 1 ? value_set.values()[0] : nullptr;
// Construct a vector of unique value IDs of the inputs.
+ // Don't add value ids where the input is equal to the definition.
std::vector<HloValue::Id> input_value_ids;
for (const InstructionValueSet* input : inputs) {
for (const HloValue* value : input->element(index).values()) {
+ if (value->defining_instruction() == instruction &&
+ value->defining_index() == index) {
+ continue;
+ }
input_value_ids.push_back(value->id());
}
}
@@ -190,6 +199,7 @@ bool HloDataflowAnalysis::Phi(
current_value->defining_instruction() == instruction &&
current_value->defining_index() == index);
if (current_value_defined_here) {
+ VLOG(5) << "current_value_defined_here: " << current_value->ToString();
CHECK(current_value->is_phi());
auto it = std::find(input_value_ids.begin(), input_value_ids.end(),
current_value->id());
@@ -197,7 +207,7 @@ bool HloDataflowAnalysis::Phi(
input_value_ids.erase(it);
}
}
-
+ VLOG(5) << "after input_value_ids.size = " << input_value_ids.size();
if (input_value_ids.empty()) {
// A value set which has at least one element should never have its value
// set reduced to zero elements. During dataflow value sets only can go