| 75 | }; |
| 76 | |
| 77 | TEST_F(DynamicPadderTest, ReduceTest) { |
| 78 | auto builder = HloComputation::Builder(TestName()); |
| 79 | auto input_shape = ShapeUtil::MakeShape(F32, {1, 2, 2}); |
| 80 | auto reduce_shape = ShapeUtil::MakeShape(F32, {2}); |
| 81 | |
| 82 | auto data_param = builder.AddInstruction( |
| 83 | HloInstruction::CreateParameter(0, input_shape, "data_param")); |
| 84 | builder.AddInstruction( |
| 85 | HloInstruction::CreateParameter(1, scalar_shape_, "size_param")); |
| 86 | |
| 87 | auto negate = builder.AddInstruction( |
| 88 | HloInstruction::CreateUnary(input_shape, HloOpcode::kNegate, data_param)); |
| 89 | |
| 90 | auto init = builder.AddInstruction( |
| 91 | HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(0.0))); |
| 92 | |
| 93 | auto reduce = builder.AddInstruction(HloInstruction::CreateReduce( |
| 94 | reduce_shape, negate, init, {0, 2}, GetScalarAddComputation())); |
| 95 | |
| 96 | module_->AddEntryComputation(builder.Build()); |
| 97 | |
| 98 | // Set up dynamic parameter binding. |
| 99 | TF_CHECK_OK(module_->dynamic_parameter_binding().Bind( |
| 100 | DynamicParameterBinding::DynamicParameter{1, {}}, |
| 101 | DynamicParameterBinding::DynamicDimension{0, {}, 1})); |
| 102 | |
| 103 | TF_ASSERT_OK(RunPadder().status()); |
| 104 | |
| 105 | ExpectPadded(reduce->operand(0)); |
| 106 | } |
| 107 | |
| 108 | TEST_F(DynamicPadderTest, ConvolutionTest) { |
| 109 | auto builder = HloComputation::Builder(TestName()); |
nothing calls this directly
no test coverage detected