diff options
author | 2018-09-12 20:32:37 -0700 | |
---|---|---|
committer | 2018-09-12 20:36:47 -0700 | |
commit | f4d8442e13356ab645446c9f4a9b3b6cedddcd63 (patch) | |
tree | 0538dabff85c0cd8a64be7bc0a589482bd7a859c /tensorflow/compiler/xla/service/hlo_module_dce.cc | |
parent | f03e8e0b9b149f95003099937dd35a220e3dfc95 (diff) |
Do not DCE while bodies which have IO operations.
PiperOrigin-RevId: 212750173
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_module_dce.cc')
-rw-r--r-- | tensorflow/compiler/xla/service/hlo_module_dce.cc | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_module_dce.cc b/tensorflow/compiler/xla/service/hlo_module_dce.cc index 98d20315e3..f7be5cae22 100644 --- a/tensorflow/compiler/xla/service/hlo_module_dce.cc +++ b/tensorflow/compiler/xla/service/hlo_module_dce.cc @@ -36,23 +36,6 @@ namespace xla { namespace { -bool HasSendRecv(HloComputation* computation) { - for (auto* instruction : computation->instructions()) { - if (instruction->opcode() == HloOpcode::kSend || - instruction->opcode() == HloOpcode::kSendDone || - instruction->opcode() == HloOpcode::kRecv || - instruction->opcode() == HloOpcode::kRecvDone) { - return true; - } - for (auto* sub_computation : instruction->called_computations()) { - if (HasSendRecv(sub_computation)) { - return true; - } - } - } - return false; -} - StatusOr<bool> RunWhileDCE(HloModule* module, HloLivenessAnalysis* liveness) { bool changed = false; for (auto* computation : module->computations()) { @@ -68,9 +51,10 @@ StatusOr<bool> RunWhileDCE(HloModule* module, HloLivenessAnalysis* liveness) { if (!ShapeUtil::IsTuple(xla_while->shape()) || while_body_root->opcode() != HloOpcode::kTuple || - HasSendRecv(while_body_comp)) { + while_body_comp->HasSideEffect() || + xla_while->while_condition()->HasSideEffect()) { // Only run DCE on tuple-shaped while loops where body root is Tuple, - // with no send/recv instructions. + // with no I/O instructions. VLOG(1) << "WhileDCE SKIP while: " << xla_while->ToString(); continue; } |