-
Notifications
You must be signed in to change notification settings - Fork 2
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
8 changed files
with
136 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,38 @@ | ||
name = "TypeParameterAccessors" | ||
uuid = "7e5a90cf-f82e-492e-a09b-e3e26432c138" | ||
authors = ["ITensor developers <[email protected]> and contributors"] | ||
version = "0.3.0" | ||
version = "0.3.1" | ||
|
||
[deps] | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" | ||
|
||
[weakdeps] | ||
StridedViews = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143" | ||
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" | ||
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb" | ||
Metal = "dde4c033-4e86-420c-a63e-0dd931031962" | ||
StridedViews = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143" | ||
oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" | ||
|
||
[extensions] | ||
TypeParameterAccessorsAMDGPUExt = "AMDGPU" | ||
TypeParameterAccessorsCUDAExt = "CUDA" | ||
TypeParameterAccessorsFillArraysExt = "FillArrays" | ||
TypeParameterAccessorsJLArraysExt = "JLArrays" | ||
TypeParameterAccessorsMetalExt = "Metal" | ||
TypeParameterAccessorsStridedViewsExt = "StridedViews" | ||
TypeParameterAccessorsoneAPIExt = "oneAPI" | ||
|
||
[compat] | ||
AMDGPU = "0, 1" | ||
CUDA = "3, 4, 5" | ||
FillArrays = "1.13" | ||
JLArrays = "0.1, 0.2" | ||
LinearAlgebra = "1.10" | ||
Metal = "0, 1" | ||
SimpleTraits = "0.9.4" | ||
StridedViews = "0.3.2" | ||
julia = "1.10" | ||
|
||
[extensions] | ||
TypeParameterAccessorsStridedViewsExt = "StridedViews" | ||
TypeParameterAccessorsFillArraysExt = "FillArrays" | ||
oneAPI = "0, 1, 2" |
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,9 @@ | ||
module TypeParameterAccessorsAMDGPUExt | ||
|
||
using AMDGPU: ROCArray | ||
using TypeParameterAccessors: TypeParameterAccessors, Position | ||
|
||
TypeParameterAccessors.position(::Type{<:ROCArray}, ::typeof(eltype)) = Position(1) | ||
TypeParameterAccessors.position(::Type{<:ROCArray}, ::typeof(ndims)) = Position(2) | ||
|
||
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,9 @@ | ||
module TypeParameterAccessorsCUDAExt | ||
|
||
using CUDA: CuArray | ||
using TypeParameterAccessors: TypeParameterAccessors, Position | ||
|
||
TypeParameterAccessors.position(::Type{<:CuArray}, ::typeof(eltype)) = Position(1) | ||
TypeParameterAccessors.position(::Type{<:CuArray}, ::typeof(ndims)) = Position(2) | ||
|
||
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,9 @@ | ||
module TypeParameterAccessorsJLArraysExt | ||
|
||
using JLArrays: JLArray | ||
using TypeParameterAccessors: TypeParameterAccessors, Position | ||
|
||
TypeParameterAccessors.position(::Type{<:JLArray}, ::typeof(eltype)) = Position(1) | ||
TypeParameterAccessors.position(::Type{<:JLArray}, ::typeof(ndims)) = Position(2) | ||
|
||
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,9 @@ | ||
module TypeParameterAccessorsMetalExt | ||
|
||
using Metal: MtlArray | ||
using TypeParameterAccessors: TypeParameterAccessors, Position | ||
|
||
TypeParameterAccessors.position(::Type{<:MtlArray}, ::typeof(eltype)) = Position(1) | ||
TypeParameterAccessors.position(::Type{<:MtlArray}, ::typeof(ndims)) = Position(2) | ||
|
||
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,9 @@ | ||
module TypeParameterAccessorsoneAPIExt | ||
|
||
using oneAPI: oneArray | ||
using TypeParameterAccessors: TypeParameterAccessors, Position | ||
|
||
TypeParameterAccessors.position(::Type{<:oneArray}, ::typeof(eltype)) = Position(1) | ||
TypeParameterAccessors.position(::Type{<:oneArray}, ::typeof(ndims)) = Position(2) | ||
|
||
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
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 |
---|---|---|
@@ -1,64 +1,80 @@ | ||
using JLArrays: JLArray, JLMatrix, JLVector | ||
using Test: @test, @test_throws, @test_broken, @testset | ||
using TestExtras: @constinferred | ||
using TypeParameterAccessors: | ||
set_type_parameters, specify_type_parameters, type_parameters, unspecify_type_parameters | ||
|
||
@testset "Get parameters" begin | ||
@test @constinferred(type_parameters($(AbstractArray{Float64}), 1)) == Float64 | ||
@test @constinferred(type_parameters($(AbstractArray{Float64}), eltype)) == Float64 | ||
@test @constinferred(type_parameters($(AbstractMatrix{Float64}), ndims)) == 2 | ||
const anyarrayts = ( | ||
(arrayt=Array, matrixt=Matrix, vectort=Vector), | ||
(arrayt=JLArray, matrixt=JLMatrix, vectort=JLVector), | ||
) | ||
@testset "basics (arrayts=$anyarrayt)" for anyarrayt in anyarrayts | ||
(; arrayt, matrixt, vectort) = anyarrayt | ||
|
||
@test @constinferred(type_parameters($(Array{Float64}), 1)) == Float64 | ||
@test @constinferred(type_parameters($(Val{3}))) == (3,) | ||
@testset "Get parameters" begin | ||
@test @constinferred(type_parameters($(AbstractArray{Float64}), 1)) == Float64 | ||
@test @constinferred(type_parameters($(AbstractArray{Float64}), eltype)) == Float64 | ||
@test @constinferred(type_parameters($(AbstractMatrix{Float64}), ndims)) == 2 | ||
|
||
# @test_throws ErrorException type_parameter(Array, 1) | ||
@test @constinferred(type_parameters($(Array{Float64}), eltype)) == Float64 | ||
@test @constinferred(type_parameters($(Matrix{Float64}), ndims)) == 2 | ||
@test @constinferred(type_parameters($(Matrix{Float64}), (ndims, eltype))) == (2, Float64) | ||
# TODO: Not inferrable without interpolating positions: | ||
# https://github.com/ITensor/TypeParameterAccessors.jl/issues/21. | ||
@test @constinferred(type_parameters($(Matrix{Float64}), $((2, eltype)))) == (2, Float64) | ||
@test @constinferred(type_parameters($(Matrix{Float64}), (ndims, eltype))) == (2, Float64) | ||
# @test_throws ErrorException type_parameters(Array{Float64}, ndims) == 2 | ||
@test @constinferred(broadcast($type_parameters, $(Matrix{Float64}), $((2, eltype)))) == | ||
(2, Float64) | ||
end | ||
@test @constinferred(type_parameters($(arrayt{Float64}), 1)) == Float64 | ||
@test @constinferred(type_parameters($(Val{3}))) == (3,) | ||
|
||
@testset "Set parameters" begin | ||
@test @constinferred(set_type_parameters($Array, 1, $Float64)) == Array{Float64} | ||
@test @constinferred(set_type_parameters($Array, 2, 2)) == Matrix | ||
@test @constinferred(set_type_parameters($Array, $eltype, $Float32)) == Array{Float32} | ||
@test @constinferred(set_type_parameters($Array, $((eltype, 2)), $((Float32, 3)))) == | ||
Array{Float32,3} | ||
end | ||
# @test_throws ErrorException type_parameter(arrayt, 1) | ||
@test @constinferred(type_parameters($(arrayt{Float64}), eltype)) == Float64 | ||
@test @constinferred(type_parameters($(matrixt{Float64}), ndims)) == 2 | ||
@test @constinferred(type_parameters($(matrixt{Float64}), (ndims, eltype))) == | ||
(2, Float64) | ||
# TODO: Not inferrable without interpolating positions: | ||
# https://github.com/ITensor/TypeParameterAccessors.jl/issues/21. | ||
@test @constinferred(type_parameters($(matrixt{Float64}), $((2, eltype)))) == | ||
(2, Float64) | ||
@test @constinferred(type_parameters($(matrixt{Float64}), (ndims, eltype))) == | ||
(2, Float64) | ||
# @test_throws ErrorException type_parameters(arrayt{Float64}, ndims) == 2 | ||
@test @constinferred( | ||
broadcast($type_parameters, $(matrixt{Float64}), $((2, eltype))) | ||
) == (2, Float64) | ||
end | ||
|
||
@testset "Specify parameters" begin | ||
@test @constinferred(specify_type_parameters($Array, 1, $Float64)) == Array{Float64} | ||
@test @constinferred(specify_type_parameters($Matrix, $((2, 1)), $((4, Float32)))) == | ||
Matrix{Float32} | ||
@test @constinferred(specify_type_parameters($Array, $((Float64, 2)))) == Matrix{Float64} | ||
@test @constinferred(specify_type_parameters($Array, $eltype, $Float32)) == Array{Float32} | ||
@test @constinferred(specify_type_parameters($Array, $((eltype, 2)), $((Float32, 3)))) == | ||
Array{Float32,3} | ||
end | ||
@testset "Set parameters" begin | ||
@test @constinferred(set_type_parameters($arrayt, 1, $Float64)) == arrayt{Float64} | ||
@test @constinferred(set_type_parameters($arrayt, 2, 2)) == matrixt | ||
@test @constinferred(set_type_parameters($arrayt, $eltype, $Float32)) == arrayt{Float32} | ||
@test @constinferred(set_type_parameters($arrayt, $((eltype, 2)), $((Float32, 3)))) == | ||
arrayt{Float32,3} | ||
end | ||
|
||
@testset "Unspecify parameters" begin | ||
@test @constinferred(unspecify_type_parameters($Vector, 2)) == Array | ||
@test @constinferred(unspecify_type_parameters($(Vector{Float64}), eltype)) == Vector | ||
@test @constinferred(unspecify_type_parameters($(Vector{Float64}))) == Array | ||
@test @constinferred(unspecify_type_parameters($(Vector{Float64}), $((eltype, 2)))) == | ||
Array | ||
end | ||
@testset "Specify parameters" begin | ||
@test @constinferred(specify_type_parameters($arrayt, 1, $Float64)) == arrayt{Float64} | ||
@test @constinferred(specify_type_parameters($matrixt, $((2, 1)), $((4, Float32)))) == | ||
matrixt{Float32} | ||
@test @constinferred(specify_type_parameters($arrayt, $((Float64, 2)))) == | ||
matrixt{Float64} | ||
@test @constinferred(specify_type_parameters($arrayt, $eltype, $Float32)) == | ||
arrayt{Float32} | ||
@test @constinferred( | ||
specify_type_parameters($arrayt, $((eltype, 2)), $((Float32, 3))) | ||
) == arrayt{Float32,3} | ||
end | ||
|
||
@testset "Unspecify parameters" begin | ||
@test @constinferred(unspecify_type_parameters($vectort, 2)) == arrayt | ||
@test @constinferred(unspecify_type_parameters($(vectort{Float64}), eltype)) == vectort | ||
@test @constinferred(unspecify_type_parameters($(vectort{Float64}))) == arrayt | ||
@test @constinferred(unspecify_type_parameters($(vectort{Float64}), $((eltype, 2)))) == | ||
arrayt | ||
end | ||
|
||
@testset "On objects" begin | ||
@test @constinferred(type_parameters($(Val{3}()))) == (3,) | ||
@test @constinferred(type_parameters($(Val{Float32}()))) == (Float32,) | ||
a = randn(Float32, (2, 2, 2)) | ||
@test @constinferred(type_parameters(a, 1)) == Float32 | ||
@test @constinferred(type_parameters(a, eltype)) == Float32 | ||
@test @constinferred(type_parameters(a, 2)) == 3 | ||
@test @constinferred(type_parameters(a, ndims)) == 3 | ||
@test @constinferred(type_parameters(a)) == (Float32, 3) | ||
@test @constinferred(broadcast($type_parameters, $(Ref(a)), $((2, eltype)))) == | ||
(3, Float32) | ||
@testset "On objects" begin | ||
@test @constinferred(type_parameters($(Val{3}()))) == (3,) | ||
@test @constinferred(type_parameters($(Val{Float32}()))) == (Float32,) | ||
a = arrayt(randn(Float32, (2, 2, 2))) | ||
@test @constinferred(type_parameters(a, 1)) == Float32 | ||
@test @constinferred(type_parameters(a, eltype)) == Float32 | ||
@test @constinferred(type_parameters(a, 2)) == 3 | ||
@test @constinferred(type_parameters(a, ndims)) == 3 | ||
@test @constinferred(type_parameters(a)) == (Float32, 3) | ||
@test @constinferred(broadcast($type_parameters, $(Ref(a)), $((2, eltype)))) == | ||
(3, Float32) | ||
end | ||
end |
24b3add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
24b3add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/124740
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: