| 29 | |
| 30 | template<typename T> |
| 31 | void solveTester(const int m, const int n, const int k, double eps, |
| 32 | int targetDevice = -1) { |
| 33 | if (targetDevice >= 0) af::setDevice(targetDevice); |
| 34 | |
| 35 | af::deviceGC(); |
| 36 | |
| 37 | SUPPORTED_TYPE_CHECK(T); |
| 38 | LAPACK_ENABLED_CHECK(); |
| 39 | |
| 40 | #if 1 |
| 41 | af::array A = cpu_randu<T>(af::dim4(m, n)); |
| 42 | af::array X0 = cpu_randu<T>(af::dim4(n, k)); |
| 43 | #else |
| 44 | af::array A = af::randu(m, n, (af::dtype)af::dtype_traits<T>::af_type); |
| 45 | af::array X0 = af::randu(n, k, (af::dtype)af::dtype_traits<T>::af_type); |
| 46 | #endif |
| 47 | af::array B0 = af::matmul(A, X0); |
| 48 | |
| 49 | //! [ex_solve] |
| 50 | af::array X1 = af::solve(A, B0); |
| 51 | //! [ex_solve] |
| 52 | |
| 53 | //! [ex_solve_recon] |
| 54 | af::array B1 = af::matmul(A, X1); |
| 55 | //! [ex_solve_recon] |
| 56 | |
| 57 | ASSERT_ARRAYS_NEAR(B0, B1, eps); |
| 58 | } |
| 59 | |
| 60 | template<typename T> |
| 61 | void solveLUTester(const int n, const int k, double eps, |