diff options
author | 2017-12-22 15:22:36 -0800 | |
---|---|---|
committer | 2017-12-22 15:26:37 -0800 | |
commit | 210076afd0eb5a4c4f7f54bb079b75f92b087b3f (patch) | |
tree | 91a5fa9b2353da1107daaed124d5134f3deecc57 /tensorflow/compiler/xla/service/tuple_points_to_analysis.cc | |
parent | dbf09e3b3f2fedf374ce675ed0728096860eca73 (diff) |
Output of a slice op can alias its operand.
PiperOrigin-RevId: 179969317
Diffstat (limited to 'tensorflow/compiler/xla/service/tuple_points_to_analysis.cc')
-rw-r--r-- | tensorflow/compiler/xla/service/tuple_points_to_analysis.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc b/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc index 0c84856647..657a8fe09a 100644 --- a/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc +++ b/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc @@ -273,6 +273,16 @@ Status TuplePointsToAnalysis::HandleBitcast(HloInstruction* bitcast) { return Status::OK(); } +Status TuplePointsToAnalysis::HandleSlice(HloInstruction* slice) { + // A kSlice instruction aliases its operand if the backend lowers it to an + // in-place implementation. + if (slice->IsInPlaceSlice()) { + CreateCopiedPointsToSet(slice, slice->operand(0)); + return Status::OK(); + } + return DefaultAction(slice); +} + Status TuplePointsToAnalysis::HandleRecvDone(HloInstruction* recv_done) { // RecvDone aliases its input (Recv) tuple element {0} to its output. PointsToSet& points_to_set = CreateEmptyPointsToSet(recv_done); @@ -427,10 +437,15 @@ bool TuplePointsToAnalysis::InstructionDefinesBufferAtIndex( Status TuplePointsToAnalysis::VerifyBuffer(const LogicalBuffer& buffer) const { if (!InstructionDefinesBufferAtIndex(buffer.instruction(), buffer.index())) { - return FailedPrecondition( - "LogicalBuffer %s is ill-defined: instruction %s does not define a " - "buffer at that index", - buffer.ToString().c_str(), buffer.instruction()->name().c_str()); + // kSlice ops that are lowered to an in-place version are expected to not + // define their output buffer. + if (buffer.instruction()->opcode() != HloOpcode::kSlice || + !buffer.instruction()->IsInPlaceSlice()) { + return FailedPrecondition( + "LogicalBuffer %s is ill-defined: instruction %s does not define a " + "buffer at that index", + buffer.ToString().c_str(), buffer.instruction()->name().c_str()); + } } if (buffer.id() < 0 || |