| 180 | |
| 181 | template<typename T> |
| 182 | Array<T> qr_inplace(Array<T> &in) { |
| 183 | dim4 iDims = in.dims(); |
| 184 | int M = iDims[0]; |
| 185 | int N = iDims[1]; |
| 186 | |
| 187 | Array<T> t = createEmptyArray<T>(af::dim4(min(M, N), 1, 1, 1)); |
| 188 | |
| 189 | int lwork = 0; |
| 190 | |
| 191 | CUSOLVER_CHECK(geqrf_buf_func<T>()(solverDnHandle(), M, N, in.get(), |
| 192 | in.strides()[1], &lwork)); |
| 193 | |
| 194 | auto workspace = memAlloc<T>(lwork); |
| 195 | auto info = memAlloc<int>(1); |
| 196 | |
| 197 | CUSOLVER_CHECK(geqrf_func<T>()(solverDnHandle(), M, N, in.get(), |
| 198 | in.strides()[1], t.get(), workspace.get(), |
| 199 | lwork, info.get())); |
| 200 | |
| 201 | return t; |
| 202 | } |
| 203 | |
| 204 | #define INSTANTIATE_QR(T) \ |
| 205 | template Array<T> qr_inplace<T>(Array<T> & in); \ |