-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NDTensorsMappedArraysExt] Support for using MappedArrays as data of …
…ITensors (#1505) * [NDTensorsMappedArraysExt] Support for using MappedArrays as data of ITensors * [NDTensors] Bump to v0.3.32
- Loading branch information
Showing
9 changed files
with
89 additions
and
8 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,7 +1,7 @@ | ||
name = "NDTensors" | ||
uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" | ||
authors = ["Matthew Fishman <[email protected]>"] | ||
version = "0.3.31" | ||
version = "0.3.32" | ||
|
||
[deps] | ||
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" | ||
|
@@ -36,6 +36,7 @@ AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" | |
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" | ||
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" | ||
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" | ||
Metal = "dde4c033-4e86-420c-a63e-0dd931031962" | ||
Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" | ||
TBLIS = "48530278-0828-4a49-9772-0f3830dfa1e9" | ||
|
@@ -46,6 +47,7 @@ NDTensorsAMDGPUExt = ["AMDGPU", "GPUArraysCore"] | |
NDTensorsCUDAExt = ["CUDA", "GPUArraysCore"] | ||
NDTensorsGPUArraysCoreExt = "GPUArraysCore" | ||
NDTensorsHDF5Ext = "HDF5" | ||
NDTensorsMappedArraysExt = ["MappedArrays"] | ||
NDTensorsMetalExt = ["GPUArraysCore", "Metal"] | ||
NDTensorsOctavianExt = "Octavian" | ||
NDTensorsTBLISExt = "TBLIS" | ||
|
25 changes: 25 additions & 0 deletions
25
NDTensors/ext/NDTensorsMappedArraysExt/NDTensorsMappedArraysExt.jl
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,25 @@ | ||
module NDTensorsMappedArraysExt | ||
using MappedArrays: AbstractMappedArray | ||
using NDTensors: NDTensors | ||
function NDTensors.similar(arraytype::Type{<:AbstractMappedArray}, dims::Tuple{Vararg{Int}}) | ||
return similar(Array{eltype(arraytype)}, dims) | ||
end | ||
function NDTensors.similartype(storagetype::Type{<:AbstractMappedArray}) | ||
return Array{eltype(storagetype),ndims(storagetype)} | ||
end | ||
function NDTensors.similartype( | ||
storagetype::Type{<:AbstractMappedArray}, dims::Tuple{Vararg{Int}} | ||
) | ||
return Array{eltype(storagetype),length(dims)} | ||
end | ||
|
||
using MappedArrays: ReadonlyMappedArray | ||
using NDTensors: AllowAlias | ||
# It is a bit unfortunate that we have to define this, it fixes an ambiguity | ||
# error with MappedArrays. | ||
function (arraytype::Type{ReadonlyMappedArray{T,N,A,F}} where {T,N,A<:AbstractArray,F})( | ||
::AllowAlias, a::AbstractArray | ||
) | ||
return a | ||
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
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,4 @@ | ||
[deps] | ||
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" | ||
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" | ||
NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" |
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,12 @@ | ||
@eval module $(gensym()) | ||
using Test: @testset | ||
@testset "$(@__DIR__)" begin | ||
filenames = filter(readdir(@__DIR__)) do f | ||
startswith("test_")(f) && endswith(".jl")(f) | ||
end | ||
@testset "Test $(@__DIR__)/$filename" for filename in filenames | ||
println("Running $(@__DIR__)/$filename") | ||
include(filename) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@eval module $(gensym()) | ||
using ITensors: Index, itensor | ||
using LinearAlgebra: qr, svd | ||
using MappedArrays: mappedarray | ||
using Test: @test, @testset | ||
f(i::Int...) = float(sum(iⱼ -> iⱼ^2, i)) | ||
f(i::CartesianIndex) = f(Tuple(i)...) | ||
@testset "NDTensorsMappedArraysExt" begin | ||
a = mappedarray(f, CartesianIndices((2, 2))) | ||
b = copy(a) | ||
i, j = Index.((2, 2)) | ||
ta = itensor(a, i, j) | ||
tb = itensor(b, i, j) | ||
@test ta ≈ tb | ||
@test ta[i => 1, j => 2] ≈ tb[i => 1, j => 2] | ||
@test 2 * ta ≈ 2 * tb | ||
@test ta + ta ≈ tb + tb | ||
@test ta * ta ≈ tb * tb | ||
ua, sa, va = svd(ta, i) | ||
@test ua * sa * va ≈ ta | ||
qa, ra = qr(ta, i) | ||
@test qa * ra ≈ ta | ||
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
984d814
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 subdir=NDTensors
984d814
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/109461
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: