@@ -163,9 +163,11 @@ function (cache::LinearSolverCache)(;
163
163
cache. lincache = linres. cache
164
164
# Unfortunately LinearSolve.jl doesn't have the most uniform ReturnCode handling
165
165
if linres. retcode === ReturnCode. Failure
166
- # TODO : We need to guard this somehow because this will surely fail if A is on GPU
167
- # TODO : or some fancy Matrix type
168
- if ! (cache. linsolve isa QRFactorization{ColumnNorm})
166
+ structured_mat = ArrayInterface. isstructured (cache. lincache. A)
167
+ is_gpuarray = ArrayInterface. device (cache. lincache. A) isa ArrayInterface. GPU
168
+ if ! (cache. linsolve isa QRFactorization{ColumnNorm}) &&
169
+ ! is_gpuarray &&
170
+ ! structured_mat
169
171
if verbose
170
172
@warn " Potential Rank Deficient Matrix Detected. Attempting to solve using \
171
173
Pivoted QR Factorization."
@@ -189,6 +191,20 @@ function (cache::LinearSolverCache)(;
189
191
linres. retcode === ReturnCode. Failure &&
190
192
return LinearSolveResult (; u = linres. u, success = false )
191
193
return LinearSolveResult (; u = linres. u)
194
+ elseif ! (cache. linsolve isa QRFactorization{ColumnNorm})
195
+ if verbose
196
+ if structured_mat
197
+ @warn " Potential Rank Deficient Matrix Detected. But Matrix is \
198
+ Structured. Currently, we don't attempt to solve Rank Deficient \
199
+ Structured Matrices. Please open an issue at \
200
+ https://github.com/SciML/NonlinearSolve.jl"
201
+ elseif is_gpuarray
202
+ @warn " Potential Rank Deficient Matrix Detected. But Matrix is on GPU. \
203
+ Currently, we don't attempt to solve Rank Deficient GPU \
204
+ Matrices. Please open an issue at \
205
+ https://github.com/SciML/NonlinearSolve.jl"
206
+ end
207
+ end
192
208
end
193
209
return LinearSolveResult (; u = linres. u, success = false )
194
210
end
0 commit comments