@@ -209,8 +209,8 @@ TEST_F(WhileLoopSimplifierTest, LoopWithRecvNotSimplified) {
209209 EXPECT_FALSE (WhileLoopSimplifier ().Run (m.get ()).ValueOrDie ());
210210}
211211
212- // We can simplify loops whose bodies contain infeed or other side-effecting
213- // instructions other than send/recv .
212+ // We can't simplify loops whose bodies contain infeed or other side-effecting
213+ // instructions.
214214TEST_F (WhileLoopSimplifierTest, LoopWithInfeedSimplified) {
215215 auto m = MakeModuleWithSimpleLoop (/* num_iters=*/ 1 );
216216 HloComputation* computation = m->entry_computation ();
@@ -220,8 +220,7 @@ TEST_F(WhileLoopSimplifierTest, LoopWithInfeedSimplified) {
220220 auto token = while_body->AddInstruction (HloInstruction::CreateToken ());
221221 while_body->AddInstruction (HloInstruction::CreateInfeed (
222222 ShapeUtil::MakeShape (F32, {1 }), token, " config" ));
223- EXPECT_TRUE (WhileLoopSimplifier ().Run (m.get ()).ValueOrDie ());
224- EXPECT_THAT (m->entry_computation ()->root_instruction (), op::Tuple ());
223+ EXPECT_FALSE (WhileLoopSimplifier ().Run (m.get ()).ValueOrDie ());
225224}
226225
227226// We don't simplify trip-count-1 loops whose *conditions* contain infeed or
@@ -445,47 +444,6 @@ TEST_F(WhileLoopSimplifierTest, RemoveUnusedLoopOperands) {
445444 op::GetTupleElement (op::Parameter (0 ), /* tuple_index=*/ 1 )));
446445}
447446
448- // Check that we can remove unused loop operands even if the loop contains a
449- // side-effecting instruction.
450- TEST_F (WhileLoopSimplifierTest,
451- RemoveUnusedLoopOperandsDespiteSideEffectingOps) {
452- const string hlo_string = R"(
453- HloModule RemoveUnusedOperands
454- body {
455- loop_var = (s32[]) parameter(0)
456- gte0 = s32[] get-tuple-element(loop_var), index=0
457- token0 = token[] after-all()
458- unused = ((s32[], pred[]), token[]) infeed(token0)
459- ROOT tuple = (s32[]) tuple(gte0)
460- }
461- cond {
462- loop_var = (s32[]) parameter(0)
463- ROOT constant = pred[] constant(true)
464- }
465- ENTRY RemoveUnusedOperands {
466- x = s32[] parameter(0)
467- tuple.1 = (s32[]) tuple(s32[] x)
468- ROOT while = (s32[]) while((s32[]) tuple.1),
469- condition=cond, body=body
470- }
471- )" ;
472-
473- auto m = ParseAndReturnVerifiedModule (hlo_string).ValueOrDie ();
474- EXPECT_TRUE (WhileLoopSimplifier ().Run (m.get ()).ValueOrDie ());
475-
476- // The original while instruction is still left in the module as a dead
477- // instruction, find a while instruction with a different name as the new
478- // while instruction.
479- const auto & instrs = m->entry_computation ()->instructions ();
480- HloInstruction* new_while_op =
481- *absl::c_find_if (instrs, [&](const HloInstruction* instr) {
482- return (instr->opcode () == HloOpcode::kWhile &&
483- instr->name () != " while" );
484- });
485- EXPECT_TRUE (ShapeUtil::IsEmptyTuple (new_while_op->shape ()))
486- << new_while_op->shape ().ToString ();
487- }
488-
489447TEST_F (WhileLoopSimplifierTest, LoopWithNonTupleBodyShapeNotSimplified) {
490448 const string hlo_string = R"(
491449 HloModule BodyHasNonTupleRoot
0 commit comments