Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ext/ArrayInterfaceGPUArraysCoreExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ArrayInterfaceGPUArraysCoreExt

using Adapt
using ArrayInterface
using LinearAlgebra: lu
import LinearAlgebra
import GPUArraysCore

ArrayInterface.fast_scalar_indexing(::Type{<:GPUArraysCore.AbstractGPUArray}) = false
Expand All @@ -19,8 +19,16 @@ function ArrayInterface.restructure(x::GPUArraysCore.AbstractGPUArray, y)
reshape(Adapt.adapt(ArrayInterface.parameterless_type(x), y), Base.size(x)...)
end

# Build the `LU` directly rather than calling `lu` on an adapted array, matching the CPU
# methods in ArrayInterface.jl. Going through `lu` only works for backends that define their
# own, so it breaks on JLArrays (which downstream packages use to test GPU paths without a
# GPU) and on Metal, see #501 and #467.
function ArrayInterface.lu_instance(A::GPUArraysCore.AbstractGPUMatrix{T}) where {T}
lu(Adapt.adapt(ArrayInterface.parameterless_type(A), ones(T, 0, 0)))
noUnitT = typeof(zero(T))
luT = LinearAlgebra.lutype(noUnitT)
ipiv = similar(A, LinearAlgebra.BlasInt, 0)
info = zero(LinearAlgebra.BlasInt)
return LinearAlgebra.LU{luT}(similar(A, 0, 0), ipiv, info)
end

# Doesn't do much, but makes a gigantic change to the dependency chain.
Expand Down
Loading