| 115 | }; |
| 116 | |
| 117 | TEST_F(HloAliasAnalysisTest, BinaryOperation) { |
| 118 | // Test the analysis on a single binary operation (Add). |
| 119 | auto builder = HloComputation::Builder(TestName()); |
| 120 | auto constant1 = builder.AddInstruction( |
| 121 | HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(1.0))); |
| 122 | auto constant2 = builder.AddInstruction( |
| 123 | HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(2.0))); |
| 124 | auto add = builder.AddInstruction(HloInstruction::CreateBinary( |
| 125 | scalar_shape_, HloOpcode::kAdd, constant1, constant2)); |
| 126 | module_->AddEntryComputation(builder.Build()); |
| 127 | SCOPED_TRACE(module_->ToString()); |
| 128 | |
| 129 | const HloAliasAnalysis& analysis = RunAnalysis(); |
| 130 | |
| 131 | EXPECT_EQ(analysis.buffers().size(), 3); |
| 132 | |
| 133 | // All of the buffer sets should trivially contain a single buffer containing |
| 134 | // a single value. |
| 135 | for (const HloInstruction* instruction : {constant1, constant2, add}) { |
| 136 | EXPECT_EQ(analysis.GetUniqueBufferAt(instruction).GetUniqueValue(), |
| 137 | GetValueDefinedAt(instruction)); |
| 138 | } |
| 139 | |
| 140 | EXPECT_FALSE(analysis.InstructionBuffersAreAmbiguous(add)); |
| 141 | EXPECT_TRUE(analysis.InstructionBuffersAreDistinct(add)); |
| 142 | |
| 143 | EXPECT_FALSE(AnyValuesInSameBufferInterfere()); |
| 144 | } |
| 145 | |
| 146 | TEST_F(HloAliasAnalysisTest, TupleAndGtes) { |
| 147 | // Verify the analysis for a Tuple and GetTupleElement instructions. |
nothing calls this directly
no test coverage detected