aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/hlo_computation.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-03-28 12:56:51 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-03-28 14:08:23 -0700
commit6c42f0a1a80226692a9f37ff50e0e1356951e86c (patch)
tree372c19bd0d61e6fb774866c7969791305dacd861 /tensorflow/compiler/xla/service/hlo_computation.cc
parent622713560012c44f2903ace5c4d7fc24474ca1dd (diff)
[XLA] Add HLO verifier that checks HLO instruction's parent computation.
Change: 151494158
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_computation.cc')
-rw-r--r--tensorflow/compiler/xla/service/hlo_computation.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_computation.cc b/tensorflow/compiler/xla/service/hlo_computation.cc
index ccc2c38749..1100fd1edc 100644
--- a/tensorflow/compiler/xla/service/hlo_computation.cc
+++ b/tensorflow/compiler/xla/service/hlo_computation.cc
@@ -92,13 +92,22 @@ HloInstruction* HloComputation::AddInstructionInternal(
// Generate a unique name for the instruction.
instruction->set_name(
instruction_name_uniquer_.GetUniqueName(instruction->name()));
- instruction->set_parent(this);
+ Reparent(instruction.get());
HloInstruction* pinst = instruction.get();
instruction_iterators_[pinst] =
instructions_.insert(instructions_.end(), std::move(instruction));
return pinst;
}
+void HloComputation::Reparent(HloInstruction* instruction) {
+ instruction->set_parent(this);
+ if (instruction->opcode() == HloOpcode::kFusion) {
+ for (auto& instruction : instruction->fused_instructions()) {
+ Reparent(instruction.get());
+ }
+ }
+}
+
/* static */ bool HloComputation::IsRemovable(const HloOpcode& opcode) {
return !(opcode == HloOpcode::kParameter || opcode == HloOpcode::kRecv ||
opcode == HloOpcode::kSend || opcode == HloOpcode::kTrace ||