aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-12-22 15:22:36 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-12-22 15:26:37 -0800
commit210076afd0eb5a4c4f7f54bb079b75f92b087b3f (patch)
tree91a5fa9b2353da1107daaed124d5134f3deecc57 /tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
parentdbf09e3b3f2fedf374ce675ed0728096860eca73 (diff)
Output of a slice op can alias its operand.
PiperOrigin-RevId: 179969317
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc')
-rw-r--r--tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc b/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
index 2a335843f5..80d89d851e 100644
--- a/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
+++ b/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
@@ -276,6 +276,23 @@ bool HloDataflowAnalysis::UpdateBitcastValueSet(HloInstruction* bitcast) {
return false;
}
+bool HloDataflowAnalysis::UpdateSliceValueSet(HloInstruction* slice) {
+ CHECK_EQ(slice->opcode(), HloOpcode::kSlice);
+ if (!slice->IsInPlaceSlice()) {
+ return false;
+ }
+ // If this slice is lowered to an in-place version, then it forwards the
+ // operand value to the output.
+ const InstructionValueSet& operand_set =
+ GetInstructionValueSet(slice->operand(0));
+ InstructionValueSet& slice_set = GetInstructionValueSet(slice);
+ if (operand_set != slice_set) {
+ slice_set = operand_set;
+ return true;
+ }
+ return false;
+}
+
bool HloDataflowAnalysis::UpdateSendValueSet(HloInstruction* send) {
CHECK_EQ(send->opcode(), HloOpcode::kSend);
bool changed = false;
@@ -527,6 +544,8 @@ bool HloDataflowAnalysis::UpdateInstructionValueSet(
switch (instruction->opcode()) {
case HloOpcode::kBitcast:
return UpdateBitcastValueSet(instruction);
+ case HloOpcode::kSlice:
+ return UpdateSliceValueSet(instruction);
case HloOpcode::kCopy:
return UpdateCopyValueSet(instruction);
case HloOpcode::kGetTupleElement:
@@ -688,6 +707,11 @@ Status HloDataflowAnalysis::InitializeInstructionValueSets() {
define_all_values();
}
break;
+ case HloOpcode::kSlice:
+ if (!instruction->IsInPlaceSlice()) {
+ define_all_values();
+ }
+ break;
case HloOpcode::kWhile:
case HloOpcode::kCall:
case HloOpcode::kConditional: