Skip to content

Commit 632aeb0

Browse files
committed
ITensorList
1 parent 9543801 commit 632aeb0

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

ext/ITensorNetworksEinExprsExt/ITensorNetworksEinExprsExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ module ITensorNetworksEinExprsExt
22

33
using ITensors: Index, ITensor, @Algorithm_str, inds, noncommoninds
44
using ITensorNetworks:
5-
ITensorNetworks, ITensorNetwork, vertextype, vertex_data, contraction_sequence
5+
ITensorNetworks, ITensorList, ITensorNetwork, vertextype, vertex_data, contraction_sequence
66
using EinExprs: EinExprs, EinExpr, einexpr, SizedEinExpr
77

8-
function to_einexpr(ts::Vector{ITensor})
8+
function to_einexpr(ts::ITensorList)
99
IndexType = Any
1010

1111
tensor_exprs = EinExpr{IndexType}[]
@@ -21,7 +21,7 @@ function to_einexpr(ts::Vector{ITensor})
2121
return SizedEinExpr(sum(tensor_exprs; skip=externalinds_tn), inds_dims)
2222
end
2323

24-
function tensor_inds_to_vertex(ts::Vector{ITensor})
24+
function tensor_inds_to_vertex(ts::ITensorList)
2525
IndexType = Any
2626
VertexType = Int
2727

@@ -36,7 +36,7 @@ function tensor_inds_to_vertex(ts::Vector{ITensor})
3636
end
3737

3838
function ITensorNetworks.contraction_sequence(
39-
::Algorithm"einexpr", tn::Vector{ITensor}; optimizer=EinExprs.Exhaustive()
39+
::Algorithm"einexpr", tn::ITensorList; optimizer=EinExprs.Exhaustive()
4040
)
4141
expr = to_einexpr(tn)
4242
path = einexpr(optimizer, expr)

ext/ITensorNetworksOMEinsumContractionOrdersExt/ITensorNetworksOMEinsumContractionOrdersExt.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module ITensorNetworksOMEinsumContractionOrdersExt
22
using DocStringExtensions: TYPEDSIGNATURES
3-
using ITensorNetworks: ITensorNetworks
3+
using ITensorNetworks: ITensorNetworks, ITensorList
44
using ITensors: ITensors, Index, ITensor, inds
55
using NDTensors: dim
66
using NDTensors.AlgorithmSelection: @Algorithm_str
@@ -9,8 +9,6 @@ using OMEinsumContractionOrders: OMEinsumContractionOrders
99
# OMEinsumContractionOrders wrapper for ITensors
1010
# Slicing is not supported, because it might require extra work to slice an `ITensor` correctly.
1111

12-
const ITensorList = Union{Vector{ITensor},Tuple{Vararg{ITensor}}}
13-
1412
# infer the output tensor labels
1513
# TODO: Use `symdiff` instead.
1614
function infer_output(inputs::AbstractVector{<:AbstractVector{<:Index}})

ext/ITensorNetworksTensorOperationsExt/ITensorNetworksTensorOperationsExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module ITensorNetworksTensorOperationsExt
22

33
using ITensors: ITensors, ITensor, dim, inds
4-
using ITensorNetworks: ITensorNetworks
4+
using ITensorNetworks: ITensorNetworks, ITensorList
55
using NDTensors.AlgorithmSelection: @Algorithm_str
66
using TensorOperations: TensorOperations, optimaltree
77

8-
function ITensorNetworks.contraction_sequence(::Algorithm"optimal", tn::Vector{ITensor})
8+
function ITensorNetworks.contraction_sequence(::Algorithm"optimal", tn::ITensorList)
99
network = collect.(inds.(tn))
1010
inds_to_dims = Dict(i => dim(i) for i in unique(reduce(vcat, network)))
1111
seq, _ = optimaltree(network, inds_to_dims)

src/contraction_sequences.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ using ITensors.NDTensors: Algorithm, @Algorithm_str
44
using NamedGraphs.Keys: Key
55
using NamedGraphs.OrdinalIndexing: th
66

7-
function contraction_sequence(tn::Vector{ITensor}; alg="optimal", kwargs...)
7+
const ITensorList = Union{Vector{ITensor},Tuple{Vararg{ITensor}}}
8+
9+
function contraction_sequence(tn::ITensorList; alg="optimal", kwargs...)
810
return contraction_sequence(Algorithm(alg), tn; kwargs...)
911
end
1012

11-
function contraction_sequence(alg::Algorithm, tn::Vector{ITensor})
13+
function contraction_sequence(alg::Algorithm, tn::ITensorList)
1214
return throw(
1315
ArgumentError(
1416
"Algorithm $alg isn't defined for contraction sequence finding. Try loading a backend package like

0 commit comments

Comments
 (0)