-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsvd.jl
More file actions
64 lines (60 loc) · 2.12 KB
/
svd.jl
File metadata and controls
64 lines (60 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using MatrixAlgebraKit
using Test
using TestExtras
using StableRNGs
using LinearAlgebra: Diagonal
using CUDA, AMDGPU
using CUDA.CUSOLVER # pull in opnorm binding
BLASFloats = (Float32, Float64, ComplexF32, ComplexF64)
GenericFloats = (BigFloat, Complex{BigFloat})
@isdefined(TestSuite) || include("testsuite/TestSuite.jl")
using .TestSuite
is_buildkite = get(ENV, "BUILDKITE", "false") == "true"
for T in (BLASFloats..., GenericFloats...), m in (0, 54), n in (0, 37, m, 63)
TestSuite.seed_rng!(123)
if T ∈ BLASFloats
if CUDA.functional()
TestSuite.test_svd(CuMatrix{T}, (m, n))
CUDA_SVD_ALGS = (
CUSOLVER_QRIteration(),
CUSOLVER_SVDPolar(),
CUSOLVER_Jacobi(),
)
TestSuite.test_svd_algs(CuMatrix{T}, (m, n), CUDA_SVD_ALGS)
if n == m
TestSuite.test_svd(Diagonal{T, CuVector{T}}, m)
TestSuite.test_svd_algs(Diagonal{T, CuVector{T}}, m, (DiagonalAlgorithm(),))
end
end
if AMDGPU.functional()
TestSuite.test_svd(ROCMatrix{T}, (m, n))
AMD_SVD_ALGS = (
ROCSOLVER_QRIteration(),
ROCSOLVER_Jacobi(),
)
TestSuite.test_svd_algs(ROCMatrix{T}, (m, n), AMD_SVD_ALGS)
if n == m
TestSuite.test_svd(Diagonal{T, ROCVector{T}}, m)
TestSuite.test_svd_algs(Diagonal{T, ROCVector{T}}, m, (DiagonalAlgorithm(),))
end
end
end
if !is_buildkite
if T ∈ BLASFloats
LAPACK_SVD_ALGS = (
LAPACK_QRIteration(),
LAPACK_DivideAndConquer(),
)
TestSuite.test_svd(T, (m, n))
TestSuite.test_svd_algs(T, (m, n), LAPACK_SVD_ALGS)
elseif T ∈ GenericFloats
TestSuite.test_svd(T, (m, n))
TestSuite.test_svd_algs(T, (m, n), (GLA_QRIteration(),))
end
if m == n
AT = Diagonal{T, Vector{T}}
TestSuite.test_svd(AT, m)
TestSuite.test_svd_algs(AT, m, (DiagonalAlgorithm(),))
end
end
end