diff --git a/Project.toml b/Project.toml index 634629a0b..7ce64cd69 100644 --- a/Project.toml +++ b/Project.toml @@ -16,6 +16,7 @@ OhMyThreads = "67456a42-1dca-4109-a031-0a68de7e3ad5" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Preferences = "21216c6a-2e73-6563-6e65-726566657250" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" +PtrArrays = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63" Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" @@ -63,6 +64,7 @@ OhMyThreads = "0.8.0" PrecompileTools = "1" Preferences = "1" Printf = "1" +PtrArrays = "1.2" Random = "1" ScopedValues = "1.3.0" Strided = "2.6.1" diff --git a/src/TensorKit.jl b/src/TensorKit.jl index 97031a665..66658521d 100644 --- a/src/TensorKit.jl +++ b/src/TensorKit.jl @@ -120,6 +120,7 @@ using MatrixAlgebraKit using Dictionaries: Dictionaries, Dictionary, Indices, gettoken, gettokenvalue using OhMyThreads +using PtrArrays: PtrArray using ScopedValues using TimerOutputs: TimerOutputs, TimerOutput, @timeit_debug diff --git a/src/tensors/treetransformers.jl b/src/tensors/treetransformers.jl index 81a96ad34..12b02cb4d 100644 --- a/src/tensors/treetransformers.jl +++ b/src/tensors/treetransformers.jl @@ -12,11 +12,12 @@ of `tsrc` itself; when `conjsrc` is `true` the fusion trees that are transformed """ abstract type TreeTransformer end -# `StridedSubblocks` report their storage as the `StridedView` parent type, which is `Memory` there +# `StridedSubblocks` report their storage as the `StridedView` parent type, which is `Memory` there; +# `PtrArray` is the storage of `TensorOperations.ManualAllocator` temporaries @static if isdefined(Core, :Memory) - const CPUStorage{T} = Union{Array{T}, Memory{T}} + const CPUStorage{T} = Union{Array{T}, Memory{T}, PtrArray{T}} else - const CPUStorage{T} = Array{T} + const CPUStorage{T} = Union{Array{T}, PtrArray{T}} end """ diff --git a/test/tensors/indexmanipulations.jl b/test/tensors/indexmanipulations.jl index c4059e00d..ef01ee48b 100644 --- a/test/tensors/indexmanipulations.jl +++ b/test/tensors/indexmanipulations.jl @@ -1,6 +1,7 @@ using Test, TestExtras using TensorKit using TensorKit: type_repr +using TensorOperations: ManualAllocator using Combinatorics: permutations @@ -211,6 +212,11 @@ for V in spacelist tdst = rand(ComplexF64, braid(space(τ), p, levels)) @test braid!(copy(tdst), τ, p, levels) ≈ braid!(copy(tdst), TensorMap(τ), p, levels) end + symmetricbraiding && @timedtestset "Permutations: ManualAllocator" begin + t = rand(ComplexF64, V1 ⊗ V2 ⊗ V3 ← V4 ⊗ V5) + p = ((3, 1, 5), (2, 4)) + @test permute(t, p; allocator = ManualAllocator()) ≈ permute(t, p) + end @timedtestset "Adjoint operands: isometry" begin # independent of the adjoint convention: a wrongly conjugated recoupling matrix U # would break dot(U * x', U * y) == dot(x', y) whenever U is genuinely complex