-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test transformations #217
Test transformations #217
Conversation
Did you find a bug? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see: the bug was in the tests.
test/Transformations_test.jl
Outdated
@@ -154,13 +152,32 @@ | |||
|
|||
# Test that the resulting tn contains no tensors with larger rank than the original | |||
rank = length ∘ size ∘ parent | |||
@test max(rank(tensors(reduced)) == max(rank(tensors(tn)))) | |||
@test max(rank.(tensors(reduced))...) <= max(rank.(tensors(tn))...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind deleting rank
and replacing it for ndims
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it's better if you call maximum
: the same as max
but without variadic arguments and can use some map
.
@test max(rank.(tensors(reduced))...) <= max(rank.(tensors(tn))...) | |
@test maximum(ndims, tensors(reduced)) <= maximum(ndims, tensors(tn)) |
test/Transformations_test.jl
Outdated
|
||
# Test that the resulting tn contains <= tensors than the original | ||
@test length(tensors(reduced)) == 1 | ||
@test length(tensors(reduced)) <= length(tensors(tn)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace length(tensors(...))
for Tenet.ntensors
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@test length(tensors(reduced)) <= length(tensors(tn)) | |
@test Tenet.ntensors(reduced) <= Tenet.ntensors(tn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tensors
needs to create a Vector
where it copies all the Tensor
s while ntensors
doesn't: it just queries the inner Dict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jofrevalles it might be worth checking if that by @inline
ing tensors
and inds
, it can optimize away the Vector
creation.
test/Transformations_test.jl
Outdated
# Options (for non-recursive) | ||
# Test that a non-recursive contraction is an intermediate simplification | ||
reduced_nonrecursive = transform(tn, ContractSimplification(:length, false)) | ||
@test length(tensors(tn)) > length(tensors(reduced_nonrecursive)) > length(tensors(reduced)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@test length(tensors(tn)) > length(tensors(reduced_nonrecursive)) > length(tensors(reduced)) | |
@test Tenet.ntensors(tn) > Tenet.ntensors(reduced_nonrecursive) > Tenent.ntensors(reduced) |
test/Transformations_test.jl
Outdated
|
||
# 2nd-stage simplification result in full simplification for this TN | ||
reduced_full = transform(reduced_nonrecursive, ContractSimplification(:length, false)) | ||
@test length(tensors(reduced)) == length(tensors(reduced_full)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@test length(tensors(reduced)) == length(tensors(reduced_full)) | |
@test Tenet.ntensors(reduced) == Tenet.ntensors(reduced_full) |
test/Transformations_test.jl
Outdated
# Options (minimization by rank) | ||
# Test that the resulting tn contains no tensors with larger rank than the original | ||
reduced_byrank = transform(tn, ContractSimplification(:rank, true)) | ||
@test max(rank.(tensors(reduced_byrank))...) <= max(rank.(tensors(tn))...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@test max(rank.(tensors(reduced_byrank))...) <= max(rank.(tensors(tn))...) | |
@test maximum(ndims, tensors(reduced_byrank)) <= maximum(ndims, tensors(tn)) |
test/Transformations_test.jl
Outdated
@test max(rank.(tensors(reduced_byrank))...) <= max(rank.(tensors(tn))...) | ||
|
||
# Test that the resulting number of tensors is bigger for a reduction by rank than for length | ||
@test length(tensors(reduced_byrank)) > length(tensors(reduced)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@test length(tensors(reduced_byrank)) > length(tensors(reduced)) | |
@test Tenet.ntensors(reduced_byrank) > Tenet.ntensors(reduced) |
test/Transformations_test.jl
Outdated
rank = length ∘ size ∘ parent | ||
@test max(rank(tensors(reduced)) == max(rank(tensors(tn)))) | ||
@test maximum(ndims, tensors(reduced)) <= maximum(ndims, tensors(tn)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the rank
definition and it should be done
No description provided.