You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/performance-tips.jl
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -30,12 +30,12 @@ probability(tn)
30
30
31
31
# For large scale applications, it is also possible to slice over certain degrees of freedom to reduce the space complexity, i.e.
32
32
# loop and accumulate over certain degrees of freedom so that one can have a smaller tensor network inside the loop due to the removal of these degrees of freedom.
33
-
#In the [`TreeSA`](@ref) optimizer, one can set `nslices` to a value larger than zero to turn on this feature.
34
-
#As a comparison we slice over 5 degrees of freedom, which can reduce the space complexity by at most 5.
33
+
#One can use the `slicer` keyword argument to reduce the space complexity by slicing over certain degrees of freedom.
34
+
#In the following example, we use the `TreeSASlicer` to reduce the space complexity to `sc_target=10`.
35
35
# In this application, the slicing achieves the largest possible space complexity reduction 5, while the time and read-write complexity are only increased by less than 1,
36
36
# i.e. the peak memory usage is reduced by a factor ``32``, while the (theoretical) computing time is increased by at a factor ``< 2``.
Copy file name to clipboardExpand all lines: src/Core.jl
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ Probabilistic modeling with a tensor network.
49
49
* `code` is the tensor network contraction pattern.
50
50
* `tensors` are the tensors fed into the tensor network, the leading tensors are unity tensors associated with `unity_tensors_labels`.
51
51
* `evidence` is a dictionary used to specify degrees of freedom that are fixed to certain values.
52
-
* `unity_tensors_idx` is a vector of indices of the unity tensors in the `tensors` array. Unity tensors are dummy tensors used to obtain the marginal probabilities.
52
+
* `unity_tensors_idx` is a vector of indices pointing to the unity tensors in the `tensors` array. Unity tensors are dummy tensors with all entries equal to one, which are used to obtain the marginal probabilities.
53
53
"""
54
54
struct TensorNetworkModel{ET, MT <:AbstractArray}
55
55
nvars::Int
@@ -118,6 +118,7 @@ function TensorNetworkModel(
118
118
evidence =Dict{Int,Int}(),
119
119
optimizer =GreedyMethod(),
120
120
simplifier =nothing,
121
+
slicer =nothing,
121
122
unity_tensors_labels = [[i] for i=1:model.nvars]
122
123
) where {ET, FT}
123
124
# `optimize_code` optimizes the contraction order of a raw tensor network without a contraction order specified.
@@ -127,7 +128,7 @@ function TensorNetworkModel(
127
128
rawcode =EinCode([unity_tensors_labels..., [[factor.vars...] for factor in model.factors]...], collect(Int, openvars)) # labels for vertex tensors (unity tensors) and edge tensors
128
129
tensors = Array{ET}[[ones(ET, [model.cards[i] for i in lb]...) for lb in unity_tensors_labels]..., [t.vals for t in model.factors]...]
0 commit comments