| 59 | |
| 60 | template<typename T> |
| 61 | void solveLUTester(const int n, const int k, double eps, |
| 62 | int targetDevice = -1) { |
| 63 | if (targetDevice >= 0) af::setDevice(targetDevice); |
| 64 | |
| 65 | af::deviceGC(); |
| 66 | |
| 67 | SUPPORTED_TYPE_CHECK(T); |
| 68 | LAPACK_ENABLED_CHECK(); |
| 69 | |
| 70 | #if 1 |
| 71 | af::array A = cpu_randu<T>(af::dim4(n, n)); |
| 72 | af::array X0 = cpu_randu<T>(af::dim4(n, k)); |
| 73 | #else |
| 74 | af::array A = af::randu(n, n, (af::dtype)af::dtype_traits<T>::af_type); |
| 75 | af::array X0 = af::randu(n, k, (af::dtype)af::dtype_traits<T>::af_type); |
| 76 | #endif |
| 77 | af::array B0 = af::matmul(A, X0); |
| 78 | |
| 79 | //! [ex_solve_lu] |
| 80 | af::array A_lu, pivot; |
| 81 | af::lu(A_lu, pivot, A); |
| 82 | af::array X1 = af::solveLU(A_lu, pivot, B0); |
| 83 | //! [ex_solve_lu] |
| 84 | |
| 85 | af::array B1 = af::matmul(A, X1); |
| 86 | |
| 87 | ASSERT_ARRAYS_NEAR(B0, B1, eps); |
| 88 | } |
| 89 | |
| 90 | template<typename T> |
| 91 | void solveTriangleTester(const int n, const int k, bool is_upper, double eps, |