@@ -97,7 +97,7 @@ for V in spacelist
9797 for T in (Int, Float32, ComplexF64)
9898 t = @constinferred AMDGPU. rand (T, W)
9999 d = convert (Dict, t)
100- @test TensorKit . to_cpu ( t) == convert (TensorMap, d)
100+ @test adapt (Array, t) == convert (TensorMap, d)
101101 end
102102 end
103103 symmetricbraiding && @timedtestset " Basic linear algebra" begin
@@ -189,10 +189,10 @@ for V in spacelist
189189 t = AMDGPU. rand (T, W)
190190 t2 = @constinferred AMDGPU. rand! (similar (t))
191191 α = rand (T)
192- @test norm (t, 2 ) ≈ norm (TensorKit . to_cpu ( t), 2 )
193- @test dot (t2, t) ≈ dot (TensorKit . to_cpu ( t2), TensorKit . to_cpu ( t))
194- @test TensorKit . to_cpu ( α * t) ≈ α * TensorKit . to_cpu ( t)
195- @test TensorKit . to_cpu ( t + t) ≈ 2 * TensorKit . to_cpu ( t)
192+ @test norm (t, 2 ) ≈ norm (adapt (Array, t), 2 )
193+ @test dot (t2, t) ≈ dot (adapt (Array, t2), adapt (Array, t))
194+ @test adapt (Array, α * t) ≈ α * adapt (Array, t)
195+ @test adapt (Array, t + t) ≈ 2 * adapt (Array, t)
196196 end
197197 end
198198 @timedtestset " Real and imaginary parts" begin
@@ -202,17 +202,17 @@ for V in spacelist
202202
203203 tr = @constinferred real (t)
204204 @test scalartype (tr) <: Real
205- @test real (TensorKit . to_cpu ( t)) == TensorKit . to_cpu ( tr)
205+ @test real (adapt (Array, t)) == adapt (Array, tr)
206206 @test storagetype (tr) == ROCVector{real (T), AMDGPU. Mem. HIPBuffer}
207207
208208 ti = @constinferred imag (t)
209209 @test scalartype (ti) <: Real
210- @test imag (TensorKit . to_cpu ( t)) == TensorKit . to_cpu ( ti)
210+ @test imag (adapt (Array, t)) == adapt (Array, ti)
211211 @test storagetype (ti) == ROCVector{real (T), AMDGPU. Mem. HIPBuffer}
212212
213213 tc = @inferred complex (t)
214214 @test scalartype (tc) <: Complex
215- @test complex (TensorKit . to_cpu ( t)) == TensorKit . to_cpu ( tc)
215+ @test complex (adapt (Array, t)) == adapt (Array, tc)
216216 @test storagetype (tc) == ROCVector{complex (T), AMDGPU. Mem. HIPBuffer}
217217
218218 tc2 = @inferred complex (tr, ti)
@@ -275,13 +275,13 @@ for V in spacelist
275275 p1 = ntuple (n -> p[n], k)
276276 p2 = ntuple (n -> p[k + n], 5 - k)
277277 dt2 = AMDGPU. @allowscalar permute (t, (p1, p2))
278- ht2 = permute (TensorKit . to_cpu ( t), (p1, p2))
279- @test ht2 == TensorKit . to_cpu ( dt2)
278+ ht2 = permute (adapt (Array, t), (p1, p2))
279+ @test ht2 == adapt (Array, dt2)
280280 end
281281
282282 dt3 = AMDGPU. @allowscalar repartition (t, k)
283- ht3 = repartition (TensorKit . to_cpu ( t), k)
284- @test ht3 == TensorKit . to_cpu ( dt3)
283+ ht3 = repartition (adapt (Array, t), k)
284+ @test ht3 == adapt (Array, dt3)
285285 end
286286 end
287287 symmetricbraiding && @timedtestset " Full trace: test self-consistency" begin
@@ -339,10 +339,10 @@ for V in spacelist
339339 @tensor dHrA12[a, s1, s2, c] := drhoL[a, a'] * conj(dA1[a', t1, b]) *
340340 dA2[b, t2, c'] * drhoR[c', c] *
341341 dH[s1, s2, t1, t2]
342- @tensor hHrA12[a, s1, s2, c] := TensorKit.to_cpu( drhoL)[a, a'] * conj(TensorKit.to_cpu( dA1)[a', t1, b]) *
343- TensorKit.to_cpu( dA2)[b, t2, c'] * TensorKit.to_cpu( drhoR)[c', c] *
344- TensorKit.to_cpu( dH)[s1, s2, t1, t2]
345- @test TensorKit.to_cpu( dHrA12) ≈ hHrA12
342+ @tensor hHrA12[a, s1, s2, c] := adapt(Array, drhoL)[a, a'] * conj(adapt(Array, dA1)[a', t1, b]) *
343+ adapt(Array, dA2)[b, t2, c'] * adapt(Array, drhoR)[c', c] *
344+ adapt(Array, dH)[s1, s2, t1, t2]
345+ @test adapt(Array, dHrA12) ≈ hHrA12
346346 end
347347 end=# # doesn't yet work because of AdjointTensor
348348 BraidingStyle(I) isa HasBraiding && @timedtestset "Index flipping: test flipping inverse" begin
@@ -422,31 +422,31 @@ for V in spacelist
422422 t1 = AMDGPU. rand (T, W1, W1)
423423 t2 = AMDGPU. rand (T, W2, W2)
424424 t = AMDGPU. rand (T, W1, W2)
425- ht1 = TensorKit . to_cpu ( t1)
426- ht2 = TensorKit . to_cpu ( t2)
427- ht = TensorKit . to_cpu ( t)
428- @test TensorKit . to_cpu ( t1 * t) ≈ ht1 * ht
429- @test TensorKit . to_cpu ( t1' * t) ≈ ht1' * ht
430- @test TensorKit . to_cpu ( t2 * t' ) ≈ ht2 * ht'
431- @test TensorKit . to_cpu ( t2' * t' ) ≈ ht2' * ht'
425+ ht1 = adapt (Array, t1)
426+ ht2 = adapt (Array, t2)
427+ ht = adapt (Array, t)
428+ @test adapt (Array, t1 * t) ≈ ht1 * ht
429+ @test adapt (Array, t1' * t) ≈ ht1' * ht
430+ @test adapt (Array, t2 * t' ) ≈ ht2 * ht'
431+ @test adapt (Array, t2' * t' ) ≈ ht2' * ht'
432432
433433 #= AMDGPU.@allowscalar begin
434- @test TensorKit.to_cpu( inv(t1)) ≈ inv(ht1)
435- @test TensorKit.to_cpu( pinv(t)) ≈ pinv(ht)
434+ @test adapt(Array, inv(t1)) ≈ inv(ht1)
435+ @test adapt(Array, pinv(t)) ≈ pinv(ht)
436436
437437 if T == Float32 || T == ComplexF32
438438 continue
439439 end
440440
441- @test TensorKit.to_cpu( t1 \ t) ≈ ht1 \ ht
442- @test TensorKit.to_cpu( t1' \ t) ≈ ht1' \ ht
443- @test TensorKit.to_cpu( t2 \ t') ≈ ht2 \ ht'
444- @test TensorKit.to_cpu( t2' \ t') ≈ ht2' \ ht'
441+ @test adapt(Array, t1 \ t) ≈ ht1 \ ht
442+ @test adapt(Array, t1' \ t) ≈ ht1' \ ht
443+ @test adapt(Array, t2 \ t') ≈ ht2 \ ht'
444+ @test adapt(Array, t2' \ t') ≈ ht2' \ ht'
445445
446- @test TensorKit.to_cpu( t2 / t) ≈ ht2 / ht
447- @test TensorKit.to_cpu( t2' / t) ≈ ht2' / ht
448- @test TensorKit.to_cpu( t1 / t') ≈ ht1 / ht'
449- @test TensorKit.to_cpu( t1' / t') ≈ ht1' / ht'
446+ @test adapt(Array, t2 / t) ≈ ht2 / ht
447+ @test adapt(Array, t2' / t) ≈ ht2' / ht
448+ @test adapt(Array, t1 / t') ≈ ht1 / ht'
449+ @test adapt(Array, t1' / t') ≈ ht1' / ht'
450450 end=#
451451 end
452452 end
@@ -456,11 +456,11 @@ for V in spacelist
456456 #= t = project_hermitian!(AMDGPU.randn(T, W, W))
457457 s = dim(W)
458458 @test (@constinferred sqrt(t))^2 ≈ t
459- @test TensorKit.to_cpu( sqrt(t)) ≈ sqrt(TensorKit.to_cpu( t))
459+ @test adapt(Array, sqrt(t)) ≈ sqrt(adapt(Array, t))
460460 expt = @constinferred exp(t)
461- @test TensorKit.to_cpu( expt) ≈ exp(TensorKit.to_cpu( t))
461+ @test adapt(Array, expt) ≈ exp(adapt(Array, t))
462462 @test exp(@constinferred log(project_hermitian!(expt))) ≈ expt
463- @test TensorKit.to_cpu( log(project_hermitian!(expt))) ≈ log(TensorKit.to_cpu( expt))
463+ @test adapt(Array, log(project_hermitian!(expt))) ≈ log(adapt(Array, expt))
464464
465465 @test (@constinferred cos(t))^2 + (@constinferred sin(t))^2 ≈
466466 id(storagetype(t), W)
0 commit comments