| 92 | }; |
| 93 | |
| 94 | TEST_F(BFloat16NormalizationTest, NoopIfSupported) { |
| 95 | auto builder = HloComputation::Builder(TestName()); |
| 96 | Shape f32_shape = ShapeUtil::MakeShape(F32, {2, 4}); |
| 97 | Shape bf16_shape = ShapeUtil::MakeShape(BF16, {2, 4}); |
| 98 | |
| 99 | HloInstruction* a = builder.AddInstruction( |
| 100 | HloInstruction::CreateParameter(0, f32_shape, "a")); |
| 101 | HloInstruction* b = builder.AddInstruction( |
| 102 | HloInstruction::CreateParameter(1, bf16_shape, "b")); |
| 103 | HloInstruction* c = builder.AddInstruction( |
| 104 | HloInstruction::CreateParameter(2, f32_shape, "c")); |
| 105 | |
| 106 | HloInstruction* add0 = builder.AddInstruction( |
| 107 | HloInstruction::CreateBinary(bf16_shape, HloOpcode::kAdd, a, b)); |
| 108 | |
| 109 | HloInstruction* add1 = builder.AddInstruction( |
| 110 | HloInstruction::CreateBinary(f32_shape, HloOpcode::kAdd, add0, c)); |
| 111 | |
| 112 | auto module = CreateNewVerifiedModule(); |
| 113 | auto computation = module->AddEntryComputation(builder.Build()); |
| 114 | |
| 115 | EXPECT_FALSE(Normalize(module.get())); |
| 116 | |
| 117 | EXPECT_EQ(computation->root_instruction(), add1); |
| 118 | EXPECT_EQ(add0->shape().element_type(), BF16); |
| 119 | EXPECT_EQ(add1->shape().element_type(), F32); |
| 120 | } |
| 121 | |
| 122 | TEST_F(BFloat16NormalizationTest, ResolveIfUnsupportedBF16) { |
| 123 | auto builder = HloComputation::Builder(TestName()); |
nothing calls this directly
no test coverage detected