Skip to content

Commit

Permalink
Rename RankSimplification to ContractSimplification
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Apr 28, 2024
1 parent ceae9fa commit 6c134f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/src/transformations.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Tenet.AntiDiagonalGauging
### Rank simplification

```@docs
Tenet.RankSimplification
Tenet.ContractSimplification
```

```@example plot
Expand All @@ -140,7 +140,7 @@ C = Tensor(rand(2, 2, 2), (:m, :n, :o)) #hide
E = Tensor(rand(2, 2, 2, 2), (:o, :p, :q, :j)) #hide
tn = TensorNetwork([A, B, C, E]) #hide
reduced = transform(tn, Tenet.RankSimplification) #hide
reduced = transform(tn, Tenet.ContractSimplification) #hide
smooth_annotation!( #hide
fig[1, 1]; #hide
Expand Down
8 changes: 4 additions & 4 deletions src/Transformations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,20 @@ function transform!(tn::TensorNetwork, ::HyperGroup)
end

"""
RankSimplification <: Transformation
ContractSimplification <: Transformation
Preemptively contract tensors whose result doesn't increase in size.
"""
@kwdef struct RankSimplification <: Transformation
@kwdef struct ContractSimplification <: Transformation
minimize::Symbol = :length

function RankSimplification(minimize::Symbol)
function ContractSimplification(minimize::Symbol)
@assert minimize in (:length, :rank)
return new(minimize)
end
end

function transform!(tn::TensorNetwork, config::RankSimplification)
function transform!(tn::TensorNetwork, config::ContractSimplification)
# select indices that benefit from contraction
targets = filter(inds(tn; set=:inner)) do index
candidate_tensors = select(tn, :containing, index)
Expand Down
6 changes: 3 additions & 3 deletions test/Transformations_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
end
end

@testset "RankSimplification" begin
using Tenet: RankSimplification
@testset "ContractSimplification" begin
using Tenet: ContractSimplification

# create a tensor network where tensors B and D can be absorbed
A = Tensor(rand(2, 2, 2, 2), (:i, :j, :k, :l))
Expand All @@ -125,7 +125,7 @@
E = Tensor(rand(2, 2, 2, 2), (:o, :p, :q, :j))

tn = TensorNetwork([A, B, C, D, E])
reduced = transform(tn, RankSimplification)
reduced = transform(tn, ContractSimplification)

# Test that the resulting tn contains no tensors with larger rank than the original
rank = length size parent
Expand Down

0 comments on commit 6c134f9

Please sign in to comment.