| 810 | public ::testing::WithParamInterface<BoundsLayout> {}; |
| 811 | |
| 812 | XLA_TEST_P(ReduceR3ToR2Test, ReduceR3ToR2) { |
| 813 | XlaBuilder builder(TestName()); |
| 814 | const auto& bounds = GetParam().bounds; |
| 815 | Array3D<float> input_array(bounds[0], bounds[1], bounds[2]); |
| 816 | // input_array.FillRandom(3.14f, 0.05); |
| 817 | input_array.Fill(1.0f); |
| 818 | |
| 819 | auto input_literal = LiteralUtil::CreateR3FromArray3D(input_array); |
| 820 | input_literal = |
| 821 | input_literal.Relayout(LayoutUtil::MakeLayout(GetParam().layout)); |
| 822 | std::unique_ptr<GlobalData> input_data = |
| 823 | client_->TransferToServer(input_literal).ConsumeValueOrDie(); |
| 824 | |
| 825 | auto input_activations = |
| 826 | Parameter(&builder, 0, input_literal.shape(), "input"); |
| 827 | XlaComputation add = CreateScalarAddComputation(F32, &builder); |
| 828 | Reduce(input_activations, ConstantR0<float>(&builder, 0.0f), add, |
| 829 | GetParam().reduce_dims); |
| 830 | |
| 831 | auto expected = |
| 832 | ReferenceUtil::Reduce3DTo2D(input_array, 0.0f, GetParam().reduce_dims, |
| 833 | [](float a, float b) { return a + b; }); |
| 834 | |
| 835 | ComputeAndCompareR2<float>(&builder, *expected, {input_data.get()}, |
| 836 | ErrorSpec(1e-3, 1e-3)); |
| 837 | } |
| 838 | |
| 839 | INSTANTIATE_TEST_CASE_P( |
| 840 | ReduceR3ToR2Test_Instantiation, ReduceR3ToR2Test, |
nothing calls this directly
no test coverage detected