-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module LinearOperatorsAMDGPUExt | ||
|
||
using LinearOperators | ||
isdefined(Base, :get_extension) ? (using AMDGPU) : (using ..AMDGPU) | ||
|
||
LinearOperators.storage_type(::ROCArray{T, 2, B}) where {T, B} = ROCArray{T, 1, B} | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module LinearOperatorsJLArraysExt | ||
|
||
using LinearOperators | ||
isdefined(Base, :get_extension) ? (using JLArrays) : (using ..JLArrays) | ||
|
||
LinearOperators.storage_type(::JLArray{T, 2}) where {T} = JLArray{T, 1} | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module LinearOperatorsMetalExt | ||
|
||
using LinearOperators | ||
isdefined(Base, :get_extension) ? (using Metal) : (using ..Metal) | ||
|
||
LinearOperators.storage_type(::MtlArray{T, 2, S}) where {T, S} = MtlArray{T, 1, S} | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Test, LinearAlgebra, SparseArrays | ||
using LinearOperators, AMDGPU | ||
|
||
@testset "AMDGPU -- AMDGPU.jl" begin | ||
A = ROCArray(rand(Float32, 5, 5)) | ||
B = ROCArray(rand(Float32, 10, 10)) | ||
C = ROCArray(rand(Float32, 20, 20)) | ||
M = BlockDiagonalOperator(A, B, C) | ||
|
||
v = ROCArray(rand(Float32, 35)) | ||
y = M * v | ||
@test y isa ROCArray{Float32} | ||
|
||
@testset "AMDGPU S kwarg" test_S_kwarg(arrayType = ROCArray) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test_S_kwarg(arrayType = JLArray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
using Metal | ||
test_S_kwarg(arrayType = MtlArray, notMetal = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Test, LinearOperators, LinearAlgebra | ||
|
||
function test_S_kwarg(; arrayType, notMetal = true) | ||
mat = arrayType(rand(Float32, 32, 32)) | ||
vec = arrayType(rand(Float32, 32)) | ||
vecT = typeof(vec) | ||
|
||
if notMetal | ||
# To test operators which can derive a default storage_type from their arguments | ||
vecTother = typeof(arrayType(rand(Float32, 32))) | ||
end | ||
|
||
@testset "S Kwarg with arrayType $(arrayType)" begin | ||
@test vecT == LinearOperators.storage_type(mat) | ||
|
||
# constructors.jl | ||
@test LinearOperators.storage_type(LinearOperator(mat)) == LinearOperators.storage_type(mat) # default | ||
notMetal && @test LinearOperators.storage_type(LinearOperator(mat; S = vecTother)) == vecTother | ||
@test LinearOperators.storage_type(LinearOperator(Symmetric(mat); S = vecT)) == vecT | ||
notMetal && @test LinearOperators.storage_type(LinearOperator(SymTridiagonal(Symmetric(mat)); S = vecT)) == vecT | ||
@test LinearOperators.storage_type(LinearOperator(Hermitian(mat); S = vecT)) == vecT | ||
@test LinearOperators.storage_type(LinearOperator(Float32, 32, 32, true, true, () -> 0; S = vecT)) == vecT | ||
|
||
# special-operators.jl | ||
@test LinearOperators.storage_type(opEye(Float32, 32; S = vecT)) == vecT | ||
@test LinearOperators.storage_type(opEye(Float32, 16, 32; S = vecT)) == vecT | ||
@test LinearOperators.storage_type(opEye(Float32, 32, 32; S = vecT)) == vecT | ||
|
||
@test LinearOperators.storage_type(opOnes(Float32, 32, 32; S = vecT)) == vecT | ||
@test LinearOperators.storage_type(opZeros(Float32, 32, 32; S = vecT)) == vecT | ||
|
||
@test LinearOperators.storage_type(opDiagonal(vec)) == vecT | ||
@test LinearOperators.storage_type(opDiagonal(32, 32, vec)) == vecT | ||
|
||
@test LinearOperators.storage_type(opRestriction([1, 2, 3], 32; S = vecT)) == vecT | ||
@test LinearOperators.storage_type(opExtension([1, 2, 3], 32; S = vecT)) == vecT | ||
|
||
@test LinearOperators.storage_type(BlockDiagonalOperator(mat, mat)) == vecT # default | ||
notMetal && @test LinearOperators.storage_type(BlockDiagonalOperator(mat, mat; S = vecTother)) == vecTother | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters