| 89 | |
| 90 | template <typename T> |
| 91 | void MatrixTest::TestSetMatrixDiagonal() { |
| 92 | XlaBuilder builder("GetMatrixDiagonal"); |
| 93 | Array3D<T> input(2, 3, 4); |
| 94 | input.FillIota(0); |
| 95 | for (const auto& kv : k_and_expected<T>()) { |
| 96 | XlaOp a; |
| 97 | XlaOp b; |
| 98 | auto a_data = CreateR3Parameter<T>(input, 0, "a", &builder, &a); |
| 99 | auto new_diag = |
| 100 | CreateR2Parameter<T>(Array2D<T>{kv.second}, 1, "d", &builder, &b); |
| 101 | |
| 102 | GetMatrixDiagonal(SetMatrixDiagonal(a, b + ScalarLike(b, 1), kv.first), |
| 103 | kv.first) - |
| 104 | ScalarLike(b, 1); |
| 105 | |
| 106 | ComputeAndCompareR2<T>(&builder, kv.second, {a_data.get(), new_diag.get()}); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | XLA_TEST_F(MatrixTest, SetMatrixDiagonal_S32) { |
| 111 | TestSetMatrixDiagonal<int32>(); |
nothing calls this directly
no test coverage detected