| 149 | } |
| 150 | |
| 151 | TEST_F(BroadcastTest, Broadcast_R1_2_To_R4_2x2x3x3) { |
| 152 | auto builder = HloComputation::Builder(TestName()); |
| 153 | auto input = builder.AddInstruction( |
| 154 | HloInstruction::CreateConstant(LiteralUtil::CreateR1<float>({1.0, 2.0}))); |
| 155 | |
| 156 | // Broadcast vector in dimension 1. |
| 157 | builder.AddInstruction(HloInstruction::CreateBroadcast( |
| 158 | ShapeUtil::MakeShape(F32, {2, 2, 3, 3}), input, {1})); |
| 159 | |
| 160 | // Create HLO module, compile, and execute. |
| 161 | auto hlo_module = CreateNewVerifiedModule(); |
| 162 | hlo_module->AddEntryComputation(builder.Build()); |
| 163 | auto result = ExecuteAndTransfer(std::move(hlo_module), {}); |
| 164 | |
| 165 | Array4D<float> expected(2, 2, 3, 3); |
| 166 | Array2D<float> pz({{1, 2}, {1, 2}}); |
| 167 | expected.FillWithPZ(pz); |
| 168 | |
| 169 | EXPECT_TRUE(LiteralTestUtil::Near( |
| 170 | LiteralUtil::CreateR4FromArray4D<float>(expected), result, error_spec_)); |
| 171 | } |
| 172 | |
| 173 | TEST_F(BroadcastTest, Broadcast_R1_1025_To_R4_3x3x3x1025) { |
| 174 | auto builder = HloComputation::Builder(TestName()); |
nothing calls this directly
no test coverage detected