Skip to content

Commit 9f3d83d

Browse files
committed
Add blascontractable tests
1 parent 59273c1 commit 9f3d83d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/tensor.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,4 +528,43 @@ end
528528
C3 = ncon([A], [[-1, -3, -4, -2]], [true])
529529
@test C3 conj(C)
530530
end
531+
532+
@testset "methods for StridedBLAS" begin
533+
using TensorOperations: isblascontractable, isblasdestination, makeblascontractable,
534+
StridedBLAS, DefaultAllocator
535+
backend = StridedBLAS()
536+
allocator = DefaultAllocator()
537+
538+
A = StridedView(rand(ComplexF64, 4, 4, 4, 4))
539+
540+
p = ((1, 2), (3, 4))
541+
@test isblascontractable(A, p)
542+
Anew, pnew, flag = makeblascontractable(A, p, ComplexF64, backend, allocator)
543+
@test isblascontractable(Anew, pnew)
544+
@test Anew === A
545+
546+
@test !isblascontractable(conj(A), p)
547+
Anew, pnew, flag = makeblascontractable(A, p, ComplexF64, backend, allocator)
548+
@test isblascontractable(Anew, pnew)
549+
550+
for p in (((2, 1), (3, 4)), ((1,), (3, 2, 4)), ((2, 1, 4), (3,))),
551+
op in (identity, conj)
552+
553+
@test !isblascontractable(op(A), p)
554+
Anew, pnew, flag = makeblascontractable(op(A), p, ComplexF64, backend,
555+
allocator)
556+
@test isblascontractable(Anew, pnew)
557+
end
558+
559+
vA = view(A, 1:2, 1:2, 1:2, 1:2)
560+
@test !isblascontractable(vA, p)
561+
Anew, pnew, flag = makeblascontractable(vA, p, ComplexF64, backend, allocator)
562+
@test !flag
563+
@test isblascontractable(Anew, pnew)
564+
565+
pA = permutedims(A, (3, 4, 1, 2))
566+
p = ((1, 2), (3, 4))
567+
@test isblascontractable(pA, p)
568+
@test isblascontractable(conj(pA), p)
569+
end
531570
end

0 commit comments

Comments
 (0)