| 50 | }; |
| 51 | |
| 52 | TEST_F(HloDceTest, NoDeadCode) { |
| 53 | // Verify that no dead code is removed from a computation with no dead code. |
| 54 | auto builder = HloComputation::Builder(TestName()); |
| 55 | auto constant1 = builder.AddInstruction( |
| 56 | HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(42.0f))); |
| 57 | auto constant2 = builder.AddInstruction( |
| 58 | HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(123.0f))); |
| 59 | builder.AddInstruction(HloInstruction::CreateBinary( |
| 60 | constant1->shape(), HloOpcode::kAdd, constant1, constant2)); |
| 61 | |
| 62 | auto module = CreateNewVerifiedModule(); |
| 63 | auto computation = module->AddEntryComputation(builder.Build()); |
| 64 | |
| 65 | EXPECT_EQ(3, computation->instruction_count()); |
| 66 | |
| 67 | HloDCE dce; |
| 68 | EXPECT_FALSE(dce.Run(module.get()).ValueOrDie()); |
| 69 | |
| 70 | EXPECT_EQ(3, computation->instruction_count()); |
| 71 | } |
| 72 | |
| 73 | TEST_F(HloDceTest, InstructionsWithSideEffect) { |
| 74 | // Verify that side-effect instructions (Send in this test) are not removed. |
nothing calls this directly
no test coverage detected