Skip to content

Commit c2a44bd

Browse files
committed
fix tensoralloc to support other allocators
1 parent 2abebc6 commit c2a44bd

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

src/tensors/tensoroperations.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ function TO.tensoralloc(::Type{TT},
1313
A = storagetype(TT)
1414
dim = fusionblockstructure(structure).totaldim
1515
data = TO.tensoralloc(A, dim, istemp, allocator)
16-
return TT(data, structure)
16+
# return TT(data, structure)
17+
return TensorMap{T}(data, structure)
1718
end
1819

1920
function TO.tensorfree!(t::TensorMap, allocator=TO.DefaultAllocator())

test/planar.jl

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,14 @@ end
132132
GL′ = force_planar(GL)
133133
GR′ = force_planar(GR)
134134

135-
@tensor y[-1 -2; -3] := GL[-1 2; 1] * x[1 3; 4] * O[2 -2; 3 5] * GR[4 5; -3]
136-
@planar y′[-1 -2; -3] := GL′[-1 2; 1] * x′[1 3; 4] * O′[2 -2; 3 5] * GR′[4 5; -3]
137-
@test force_planar(y) y′
135+
for alloc in
136+
(TensorOperations.DefaultAllocator(), TensorOperations.ManualAllocator())
137+
@tensor allocator = alloc y[-1 -2; -3] := GL[-1 2; 1] * x[1 3; 4] *
138+
O[2 -2; 3 5] * GR[4 5; -3]
139+
@planar allocator = alloc y′[-1 -2; -3] := GL′[-1 2; 1] * x′[1 3; 4] *
140+
O′[2 -2; 3 5] * GR′[4 5; -3]
141+
@test force_planar(y) y′
142+
end
138143

139144
# ∂AC2
140145
# -------
@@ -193,21 +198,24 @@ end
193198
ρ′ = force_planar(ρ)
194199
h′ = force_planar(h)
195200

196-
@tensor begin
197-
C = (((((((h[9 3 4; 5 1 2] * u[1 2; 7 12]) * conj(u[3 4; 11 13])) *
198-
(u[8 5; 15 6] * w[6 7; 19])) *
199-
(conj(u[8 9; 17 10]) * conj(w[10 11; 22]))) *
200-
((w[12 14; 20] * conj(w[13 14; 23])) * ρ[18 19 20; 21 22 23])) *
201-
w[16 15; 18]) * conj(w[16 17; 21]))
202-
end
203-
@planar begin
204-
C′ = (((((((h′[9 3 4; 5 1 2] * u′[1 2; 7 12]) * conj(u′[3 4; 11 13])) *
205-
(u′[8 5; 15 6] * w′[6 7; 19])) *
206-
(conj(u′[8 9; 17 10]) * conj(w′[10 11; 22]))) *
207-
((w′[12 14; 20] * conj(w′[13 14; 23])) * ρ′[18 19 20; 21 22 23])) *
208-
w′[16 15; 18]) * conj(w′[16 17; 21]))
201+
for alloc in
202+
(TensorOperations.DefaultAllocator(), TensorOperations.ManualAllocator())
203+
@tensor allocator = alloc begin
204+
C = (((((((h[9 3 4; 5 1 2] * u[1 2; 7 12]) * conj(u[3 4; 11 13])) *
205+
(u[8 5; 15 6] * w[6 7; 19])) *
206+
(conj(u[8 9; 17 10]) * conj(w[10 11; 22]))) *
207+
((w[12 14; 20] * conj(w[13 14; 23])) * ρ[18 19 20; 21 22 23])) *
208+
w[16 15; 18]) * conj(w[16 17; 21]))
209+
end
210+
@planar allocator = alloc begin
211+
C′ = (((((((h′[9 3 4; 5 1 2] * u′[1 2; 7 12]) * conj(u′[3 4; 11 13])) *
212+
(u′[8 5; 15 6] * w′[6 7; 19])) *
213+
(conj(u′[8 9; 17 10]) * conj(w′[10 11; 22]))) *
214+
((w′[12 14; 20] * conj(w′[13 14; 23])) * ρ′[18 19 20; 21 22 23])) *
215+
w′[16 15; 18]) * conj(w′[16 17; 21]))
216+
end
217+
@test C C′
209218
end
210-
@test C C′
211219
end
212220

213221
@testset "Issue 93" begin

0 commit comments

Comments
 (0)