diff --git a/lib/GPUArraysCore/src/GPUArraysCore.jl b/lib/GPUArraysCore/src/GPUArraysCore.jl index 1df83012..a6237bbc 100644 --- a/lib/GPUArraysCore/src/GPUArraysCore.jl +++ b/lib/GPUArraysCore/src/GPUArraysCore.jl @@ -6,13 +6,11 @@ using SparseArrays ## essential types export AbstractGPUArray, AbstractGPUVector, AbstractGPUMatrix, AbstractGPUVecOrMat, - WrappedGPUArray, AnyGPUArray, AbstractGPUArrayStyle, - AnyGPUArray, AnyGPUVector, AnyGPUMatrix + WrappedGPUArray, AnyGPUArray, AbstractGPUArrayStyle, + AnyGPUArray, AnyGPUVector, AnyGPUMatrix export AbstractGPUSparseArray, AbstractGPUSparseMatrix, AbstractGPUSparseVector, AbstractGPUSparseVecOrMat, - WrappedGPUSparseArray, AnyGPUSparseArray, AnyGPUSparseVector, AnyGPUSparseMatrix, - AbstractGPUSparseMatrixCSC, AbstractGPUSparseMatrixCSR, AbstractGPUSparseMatrixCOO, - WrappedGPUSparseMatrixCSC, AnyGPUSparseMatrixCSC, WrappedGPUSparseMatrixCSR, AnyGPUSparseMatrixCSR, WrappedGPUSparseMatrixCOO, AnyGPUSparseMatrixCOO + AbstractGPUSparseMatrixCSC, AbstractGPUSparseMatrixCSR, AbstractGPUSparseMatrixCOO """ AbstractGPUArray{T, N} <: DenseArray{T, N} @@ -21,44 +19,30 @@ Supertype for `N`-dimensional GPU arrays (or array-like types) with elements of Instances of this type are expected to live on the host, see [`AbstractDeviceArray`](@ref) for device-side objects. """ -abstract type AbstractGPUArray{T, N} <: DenseArray{T, N} end +abstract type AbstractGPUArray{T,N} <: DenseArray{T,N} end -const AbstractGPUVector{T} = AbstractGPUArray{T, 1} -const AbstractGPUMatrix{T} = AbstractGPUArray{T, 2} -const AbstractGPUVecOrMat{T} = Union{AbstractGPUArray{T, 1}, AbstractGPUArray{T, 2}} +const AbstractGPUVector{T} = AbstractGPUArray{T,1} +const AbstractGPUMatrix{T} = AbstractGPUArray{T,2} +const AbstractGPUVecOrMat{T} = Union{AbstractGPUArray{T,1},AbstractGPUArray{T,2}} # convenience aliases for working with wrapped arrays const WrappedGPUArray{T,N} = WrappedArray{T,N,AbstractGPUArray,AbstractGPUArray{T,N}} -const AnyGPUArray{T,N} = Union{AbstractGPUArray{T,N}, WrappedGPUArray{T,N}} -const AnyGPUVector{T} = AnyGPUArray{T, 1} -const AnyGPUMatrix{T} = AnyGPUArray{T, 2} +const AnyGPUArray{T,N} = Union{AbstractGPUArray{T,N},WrappedGPUArray{T,N}} +const AnyGPUVector{T} = AnyGPUArray{T,1} +const AnyGPUMatrix{T} = AnyGPUArray{T,2} ## sparse arrays -abstract type AbstractGPUSparseArray{Tv, Ti, N} <: AbstractSparseArray{Tv, Ti, N} end +abstract type AbstractGPUSparseArray{Tv,Ti,N} <: AbstractSparseArray{Tv,Ti,N} end -const AbstractGPUSparseMatrix{Tv, Ti} = AbstractGPUSparseArray{Tv, Ti, 2} -const AbstractGPUSparseVector{Tv, Ti} = AbstractGPUSparseArray{Tv, Ti, 1} -const AbstractGPUSparseVecOrMat{Tv, Ti} = Union{AbstractGPUSparseVector{Tv, Ti}, AbstractGPUSparseMatrix{Tv, Ti}} - -const WrappedGPUSparseArray{Tv, Ti, N} = WrappedArray{Tv,N,AbstractGPUSparseArray,AbstractGPUSparseArray{Tv, Ti, N}} -const AnyGPUSparseArray{Tv, Ti, N} = Union{AbstractGPUSparseArray{Tv, Ti, N}, WrappedGPUSparseArray{Tv, Ti, N}} -const AnyGPUSparseVector{Tv, Ti} = AnyGPUSparseArray{Tv, Ti, 1} -const AnyGPUSparseMatrix{Tv, Ti} = AnyGPUSparseArray{Tv, Ti, 2} +const AbstractGPUSparseMatrix{Tv,Ti} = AbstractGPUSparseArray{Tv,Ti,2} +const AbstractGPUSparseVector{Tv,Ti} = AbstractGPUSparseArray{Tv,Ti,1} +const AbstractGPUSparseVecOrMat{Tv,Ti} = Union{AbstractGPUSparseVector{Tv,Ti},AbstractGPUSparseMatrix{Tv,Ti}} abstract type AbstractGPUSparseMatrixCSC{Tv,Ti<:Integer} <: AbstractGPUSparseMatrix{Tv,Ti} end abstract type AbstractGPUSparseMatrixCSR{Tv,Ti<:Integer} <: AbstractGPUSparseMatrix{Tv,Ti} end abstract type AbstractGPUSparseMatrixCOO{Tv,Ti<:Integer} <: AbstractGPUSparseMatrix{Tv,Ti} end -const WrappedGPUSparseMatrixCSC{Tv,Ti} = WrappedArray{Tv,AbstractGPUSparseMatrixCSC,AbstractGPUSparseMatrixCSC{Tv,Ti}} -const AnyGPUSparseMatrixCSC{Tv,Ti} = Union{AbstractGPUSparseMatrixCSC{Tv,Ti}, WrappedGPUSparseMatrixCSC{Tv,Ti}} - -const WrappedGPUSparseMatrixCSR{Tv,Ti} = WrappedArray{Tv,AbstractGPUSparseMatrixCSR,AbstractGPUSparseMatrixCSR{Tv,Ti}} -const AnyGPUSparseMatrixCSR{Tv,Ti} = Union{AbstractGPUSparseMatrixCSR{Tv,Ti}, WrappedGPUSparseMatrixCSR{Tv,Ti}} - -const WrappedGPUSparseMatrixCOO{Tv,Ti} = WrappedArray{Tv,AbstractGPUSparseMatrixCOO,AbstractGPUSparseMatrixCOO{Tv,Ti}} -const AnyGPUSparseMatrixCOO{Tv,Ti} = Union{AbstractGPUSparseMatrixCOO{Tv,Ti}, WrappedGPUSparseMatrixCOO{Tv,Ti}} - ## broadcasting """ @@ -187,9 +171,9 @@ end # this problem will be introduced in https://github.com/JuliaLang/julia/pull/39217 macro __tryfinally(ex, fin) Expr(:tryfinally, - :($(esc(ex))), - :($(esc(fin))) - ) + :($(esc(ex))), + :($(esc(fin))) + ) end """ @@ -212,7 +196,7 @@ end function allowscalar(allow::Bool=true) if allow @warn """It's not recommended to use allowscalar([true]) to allow scalar indexing. - Instead, use `allowscalar() do end` or `@allowscalar` to denote exactly which operations can use scalar operations.""" maxlog=1 + Instead, use `allowscalar() do end` or `@allowscalar` to denote exactly which operations can use scalar operations.""" maxlog = 1 end setting = allow ? ScalarAllowed : ScalarDisallowed task_local_storage(:ScalarIndexing, setting) @@ -234,8 +218,8 @@ macro allowscalar(ex) local tls_value = get(task_local_storage(), :ScalarIndexing, nothing) task_local_storage(:ScalarIndexing, ScalarAllowed) @__tryfinally($(esc(ex)), - isnothing(tls_value) ? delete!(task_local_storage(), :ScalarIndexing) - : task_local_storage(:ScalarIndexing, tls_value)) + isnothing(tls_value) ? delete!(task_local_storage(), :ScalarIndexing) + : task_local_storage(:ScalarIndexing, tls_value)) end end