@@ -290,28 +290,29 @@ for V in spacelist
290290 @timedtestset " Permutations: test via inner product invariance" begin
291291 W = V1 ⊗ V2 ⊗ V3 ⊗ V4 ⊗ V5
292292 t = CUDA. rand (ComplexF64, W)
293+ ht = adapt (Vector{ComplexF64}, t)
293294 t′ = CUDA. randn! (similar (t))
295+ ht′ = adapt (Vector{ComplexF64}, t′)
296+ dot_htt′ = dot (ht′, ht)
297+ dot_tt′ = dot (t′, t)
298+ @test dot_tt′ ≈ dot_htt′
299+ norm_t = norm (t)
294300 for k in 0 : 5
295301 for p in permutations (1 : 5 )
296302 p1 = ntuple (n -> p[n], k)
297303 p2 = ntuple (n -> p[k + n], 5 - k)
298- CUDA. @allowscalar begin
299- t2 = @constinferred permute (t, (p1, p2))
300- t2 = permute (t, (p1, p2))
301- @test norm (t2) ≈ norm (t)
302- t2′ = permute (t′, (p1, p2))
303- @test dot (t2′, t2) ≈ dot (t′, t) ≈ dot (transpose (t2′), transpose (t2))
304- end
305- end
306-
307- CUDA. @allowscalar begin
308- t3 = @constinferred repartition (t, $ k)
309- t3 = repartition (t, k)
310- @test norm (t3) ≈ norm (t)
311- t3′ = @constinferred repartition! (similar (t3), t′)
312- @test norm (t3′) ≈ norm (t′)
313- @test dot (t′, t) ≈ dot (t3′, t3)
304+ t2 = @constinferred permute (t, (p1, p2))
305+ t2′ = permute (t′, (p1, p2))
306+ @test norm (t2) ≈ norm_t
307+ @test dot (t2′, t2) ≈ dot_tt′
308+ @test dot (transpose (t2′), transpose (t2)) ≈ dot_tt′
314309 end
310+ t3 = @constinferred repartition (t, $ k)
311+ t3 = repartition (t, k)
312+ t3′ = @constinferred repartition! (similar (t3), t′)
313+ @test norm (t3) ≈ norm (t)
314+ @test norm (t3′) ≈ norm (t′)
315+ @test dot (t′, t) ≈ dot (t3′, t3)
315316 end
316317 end
317318 if BraidingStyle (I) isa SymmetricBraiding
@@ -322,34 +323,35 @@ for V in spacelist
322323 for p in permutations (1 : 5 )
323324 p1 = ntuple (n -> p[n], k)
324325 p2 = ntuple (n -> p[k + n], 5 - k)
325- dt2 = CUDA. @allowscalar permute (t, (p1, p2))
326- ht2 = permute (TensorKit. to_cpu (t), (p1, p2))
327- @test ht2 == adapt (Vector{ComplexF64}, dt2)
326+ ht2 = permute (adapt (Vector{ComplexF64}, t), (p1, p2))
327+ dt2 = permute (t, (p1, p2))
328+ @test ht2 ≈ adapt (Vector{ComplexF64}, dt2)
329+ ht3 = transpose (adapt (Vector{ComplexF64}, dt2))
330+ dt3 = transpose (dt2)
331+ hht3 = adapt (Vector{ComplexF64}, dt3)
332+ @test ht3 ≈ hht3
328333 end
329-
330- dt3 = CUDA. @allowscalar repartition (t, k)
331- ht3 = repartition (adapt (Vector{ComplexF64}, t), k)
332- @test ht3 == adapt (Vector{ComplexF64}, dt3)
334+ dt4 = repartition (t, k)
335+ ht4 = repartition (adapt (Vector{ComplexF64}, t), k)
336+ @test ht4 == adapt (Vector{ComplexF64}, dt4)
333337 end
334338 end
335339 end
336340 @timedtestset " Full trace: test self-consistency" begin
337341 t = CUDA. rand (ComplexF64, V1 ⊗ V2' ⊗ V2 ⊗ V1' )
338- CUDA. @allowscalar begin
339- t2 = permute (t, ((1 , 2 ), (4 , 3 )))
340- s = @constinferred tr (t2)
341- @test conj (s) ≈ tr (t2' )
342- if ! isdual (V1)
343- t2 = twist! (t2, 1 )
344- end
345- if isdual (V2)
346- t2 = twist! (t2, 2 )
347- end
348- ss = tr (t2)
349- @tensor s2 = t[a, b, b, a]
350- @tensor t3[a, b] := t[a, c, c, b]
351- @tensor s3 = t3[a, a]
342+ t2 = permute (t, ((1 , 2 ), (4 , 3 )))
343+ s = @constinferred tr (t2)
344+ @test conj (s) ≈ tr (t2' )
345+ if ! isdual (V1)
346+ t2 = twist! (t2, 1 )
352347 end
348+ if isdual (V2)
349+ t2 = twist! (t2, 2 )
350+ end
351+ ss = tr (t2)
352+ @tensor s2 = t[a, b, b, a]
353+ @tensor t3[a, b] := t[a, c, c, b]
354+ @tensor s3 = t3[a, a]
353355 @test ss ≈ s2
354356 @test ss ≈ s3
355357 end
@@ -363,24 +365,20 @@ for V in spacelist
363365 if BraidingStyle (I) isa Bosonic && hasfusiontensor (I)
364366 @timedtestset " Trace: test via conversion" begin
365367 t = CUDA. rand (ComplexF64, V1 ⊗ V2' ⊗ V3 ⊗ V2 ⊗ V1' ⊗ V3' )
366- CUDA. @allowscalar begin
367- @tensor t2[a, b] := t[c, d, b, d, c, a]
368- @tensor t3[a, b] := ad (t)[c, d, b, d, c, a]
369- end
368+ @tensor t2[a, b] := t[c, d, b, d, c, a]
369+ @tensor t3[a, b] := ad (t)[c, d, b, d, c, a]
370370 @test t3 ≈ ad (t2)
371371 end
372372 end
373373 @timedtestset " Trace and contraction" begin
374374 t1 = CUDA. rand (ComplexF64, V1 ⊗ V2 ⊗ V3)
375375 t2 = CUDA. rand (ComplexF64, V2' ⊗ V4 ⊗ V1' )
376- CUDA. @allowscalar begin
377- t3 = t1 ⊗ t2
378- @tensor ta[a, b] := t1[x, y, a] * t2[y, b, x]
379- @tensor tb[a, b] := t3[x, y, a, y, b, x]
380- end
376+ t3 = t1 ⊗ t2
377+ @tensor ta[a, b] := t1[x, y, a] * t2[y, b, x]
378+ @tensor tb[a, b] := t3[x, y, a, y, b, x]
381379 @test ta ≈ tb
382380 end
383- #= if BraidingStyle(I) isa Bosonic && hasfusiontensor(I)
381+ if BraidingStyle (I) isa Bosonic && hasfusiontensor (I)
384382 @timedtestset " Tensor contraction: test via CPU" begin
385383 dA1 = CUDA. randn (ComplexF64, V1' * V2' , V3' )
386384 dA2 = CUDA. randn (ComplexF64, V3 * V4, V5)
@@ -395,7 +393,7 @@ for V in spacelist
395393 TensorKit. to_cpu (dH)[s1, s2, t1, t2]
396394 @test TensorKit. to_cpu (dHrA12) ≈ hHrA12
397395 end
398- end=# # doesn't yet work because of AdjointTensor
396+ end
399397 @timedtestset " Index flipping: test flipping inverse" begin
400398 t = CUDA. rand (ComplexF64, V1 ⊗ V1' ← V1' ⊗ V1)
401399 for i in 1 : 4
@@ -405,7 +403,7 @@ for V in spacelist
405403 end
406404 end
407405 end
408- #= @timedtestset "Index flipping: test via explicit flip" begin
406+ @timedtestset " Index flipping: test via explicit flip" begin
409407 t = CUDA. rand (ComplexF64, V1 ⊗ V1' ← V1' ⊗ V1)
410408 F1 = unitary (flip (V1), V1)
411409
@@ -433,7 +431,7 @@ for V in spacelist
433431 @tensor tb[a, b] := flip (t1, (1 , 3 ))[x, y, a, z] * flip (t2, (2 , 4 ))[y, b, z, x]
434432 @test flip (ta, (1 , 2 )) ≈ tb
435433 end
436- end=# # TODO
434+ end
437435 @timedtestset " Multiplication of isometries: test properties" begin
438436 W2 = V4 ⊗ V5
439437 W1 = W2 ⊗ (oneunit (V1) ⊕ oneunit (V1))
0 commit comments