MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / XLA_TEST_P

Function XLA_TEST_P

tensorflow/compiler/xla/tests/reduce_test.cc:812–837  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810 public ::testing::WithParamInterface<BoundsLayout> {};
811
812XLA_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
839INSTANTIATE_TEST_CASE_P(
840 ReduceR3ToR2Test_Instantiation, ReduceR3ToR2Test,

Callers

nothing calls this directly

Calls 13

TestNameFunction · 0.85
GetParamFunction · 0.85
RelayoutMethod · 0.80
ConsumeValueOrDieMethod · 0.80
ErrorSpecClass · 0.70
MakeLayoutFunction · 0.50
ParameterFunction · 0.50
ReduceFunction · 0.50
FillMethod · 0.45
TransferToServerMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected