Skip to content

Commit 88c7b29

Browse files
authored
Don't say AMD + Diagonal supports ragged batches (#305)
* Don't say AMD + Diagonal supports ragged batches * Make sure Diagonal doesn't report that it supports ragged batches
1 parent 51c53fa commit 88c7b29

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎ext/MatrixAlgebraKitAMDGPUExt/MatrixAlgebraKitAMDGPUExt.jl‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ MatrixAlgebraKit.supports_svd_full(::ROCSOLVER, f::Symbol) = f in (:qr_iteration
4141
# rocSOLVER's `gesvd*_batched` functions take the batch as an array
4242
# of device pointers, so a group of equally sized matrices
4343
# doesn't need a copy into a 3D ROCArray.
44-
MatrixAlgebraKit.supports_pointer_batch(::AbstractAlgorithm, ::ROCSOLVER, ::Type{<:StridedROCMatrix{<:BlasFloat}}) = true
45-
MatrixAlgebraKit.supports_ragged_batch(::typeof(svd_full!), ::AbstractAlgorithm, ::ROCSOLVER, ::Type{<:AnyROCArray}) = true
46-
MatrixAlgebraKit.supports_ragged_batch(::typeof(svd_compact!), ::AbstractAlgorithm, ::ROCSOLVER, ::Type{<:AnyROCArray}) = true
47-
MatrixAlgebraKit.supports_ragged_batch(::typeof(svd_vals!), ::AbstractAlgorithm, ::ROCSOLVER, ::Type{<:AnyROCArray}) = true
44+
# opt-in per algorithm to avoid picking up `DiagonalAlgorithm`
45+
# which doesn't support batching
46+
for alg in (:Bisection, :Jacobi, :QRIteration, :DivideAndConquer)
47+
@eval MatrixAlgebraKit.supports_pointer_batch(::$alg, ::ROCSOLVER, ::Type{<:StridedROCMatrix{<:BlasFloat}}) = true
48+
@eval MatrixAlgebraKit.supports_ragged_batch(::typeof(svd_full!), ::$alg, ::ROCSOLVER, ::Type{<:AnyROCArray}) = true
49+
@eval MatrixAlgebraKit.supports_ragged_batch(::typeof(svd_compact!), ::$alg, ::ROCSOLVER, ::Type{<:AnyROCArray}) = true
50+
@eval MatrixAlgebraKit.supports_ragged_batch(::typeof(svd_vals!), ::$alg, ::ROCSOLVER, ::Type{<:AnyROCArray}) = true
51+
end
4852

4953
function gesvd!(::ROCSOLVER, A::StridedROCMatrix, S::StridedROCVector, U::StridedROCMatrix, Vᴴ::StridedROCMatrix; kwargs...)
5054
m, n = size(A)

‎test/decompositions/svd.jl‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ if CUDA.functional()
6868
TestSuite.test_svd_algs_batched_oversized(CuMatrix{T}, (Jacobi(),), batch_size)
6969
TestSuite.test_svd_algs_batched_ragged_support(CuMatrix{T}, (Jacobi(),), batch_size)
7070
TestSuite.test_svd_algs_batched_ragged_support(CuMatrix{T}, (QRIteration(),), batch_size; supported = false)
71+
TestSuite.test_svd_algs_batched_ragged_support(Diagonal{T, CuVector{T}}, (DiagonalAlgorithm(),), batch_size; supported = false)
7172
end
7273

7374
# Randomized SVD:
@@ -104,6 +105,7 @@ if AMDGPU.functional()
104105
TestSuite.seed_rng!(123)
105106
AMD_SVD_ALGS = (QRIteration(), Jacobi(), DivideAndConquer(), Bisection())
106107
TestSuite.test_svd_algs_batched_ragged_support(ROCMatrix{T}, AMD_SVD_ALGS, batch_size)
108+
TestSuite.test_svd_algs_batched_ragged_support(Diagonal{T, ROCVector{T}}, (DiagonalAlgorithm(),), batch_size; supported = false)
107109
end
108110

109111
@testset "Bisection with min(m, n) == 1 $(testargs_summary(T, sz))" for T in BLASFloats,

0 commit comments

Comments
 (0)