| 112 | |
| 113 | template<typename T> |
| 114 | Array<int> lu_inplace(Array<T> &in, const bool convert_pivot) { |
| 115 | dim4 iDims = in.dims(); |
| 116 | int M = iDims[0]; |
| 117 | int N = iDims[1]; |
| 118 | |
| 119 | Array<int> pivot = createEmptyArray<int>(af::dim4(std::min(M, N), 1, 1, 1)); |
| 120 | |
| 121 | int lwork = 0; |
| 122 | |
| 123 | CUSOLVER_CHECK(getrf_buf_func<T>()(solverDnHandle(), M, N, in.get(), |
| 124 | in.strides()[1], &lwork)); |
| 125 | |
| 126 | auto workspace = memAlloc<T>(lwork); |
| 127 | auto info = memAlloc<int>(1); |
| 128 | |
| 129 | CUSOLVER_CHECK(getrf_func<T>()(solverDnHandle(), M, N, in.get(), |
| 130 | in.strides()[1], workspace.get(), |
| 131 | pivot.get(), info.get())); |
| 132 | |
| 133 | if (convert_pivot) { convertPivot(pivot, M); } |
| 134 | |
| 135 | return pivot; |
| 136 | } |
| 137 | |
| 138 | bool isLAPACKAvailable() { return true; } |
| 139 |
no test coverage detected