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

Function XLA_TEST_P

tensorflow/compiler/xla/tests/triangular_solve_test.cc:453–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

451 public ::testing::WithParamInterface<TriangularSolveTestSpec> {};
452
453XLA_TEST_P(TriangularSolveParametricTest, Random) {
454 TriangularSolveTestSpec spec = GetParam();
455
456 XlaBuilder builder(TestName());
457
458 Array2D<float> avals(spec.m, spec.m);
459 avals.FillRandom(1.0);
460 for (int i = 0; i < spec.m; ++i) {
461 avals(i, i) += 10;
462 }
463
464 std::pair<int, int> bdims = spec.left_side ? std::make_pair(spec.m, spec.n)
465 : std::make_pair(spec.n, spec.m);
466 Array2D<float> bvals(bdims.first, bdims.second);
467 bvals.FillRandom(1.0);
468
469 XlaOp a, b;
470 auto a_data = CreateR2Parameter<float>(avals, 0, "a", &builder, &a);
471 auto b_data = CreateR2Parameter<float>(bvals, 1, "b", &builder, &b);
472 auto x = TriangularSolve(a, b, spec.left_side, spec.lower,
473 /*unit_diagonal=*/false, spec.transpose_a);
474 auto a_tri = Triangle(a, spec.lower);
475 a_tri = MaybeTransposeInMinorDims(
476 a_tri, spec.transpose_a != TriangularSolveOptions::NO_TRANSPOSE);
477 if (spec.left_side) {
478 BatchDot(a_tri, x);
479 } else {
480 BatchDot(x, a_tri);
481 }
482
483 ComputeAndCompareR2<float>(&builder, bvals, {a_data.get(), b_data.get()},
484 ErrorSpec(1e-2, 1e-2));
485}
486
487std::vector<TriangularSolveTestSpec> TriangularSolveTests() {
488 std::vector<TriangularSolveTestSpec> specs;

Callers

nothing calls this directly

Calls 9

GetParamFunction · 0.85
TestNameFunction · 0.85
TriangularSolveFunction · 0.85
TriangleFunction · 0.85
BatchDotFunction · 0.85
ErrorSpecClass · 0.70
FillRandomMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected