TensorBFS / OMEinsumContractionOrders.jl

Tensor network contraction order optimizers for OMEinsum
MIT License
25 stars 3 forks source link

Refactor interface #16

Closed GiggleLiu closed 3 years ago

GiggleLiu commented 3 years ago

The new interface looks like:

julia> using OMEinsum, OMEinsumContractionOrders, LightGraphs, KaHyPar

julia> function random_regular_eincode(n, k; optimize=nothing)
        g = LightGraphs.random_regular_graph(n, k)
        ixs = [minmax(e.src,e.dst) for e in LightGraphs.edges(g)]
        return EinCode((ixs..., [(i,) for i in     LightGraphs.vertices(g)]...), ())
    end

julia> code = random_regular_eincode(200, 3);

julia> optcode_tree = optimize_code(code, uniformsize(code, 2), TreeSA(sc_target=28, βs=0.1:0.1:10, ntrials=2, niters=100, sc_weight=3.0));

julia> optcode_kahypar = optimize_code(code, uniformsize(code, 2), KaHyParBipartite(sc_target=30, max_group_size=50));

julia> optcode_sa = optimize_code(code, uniformsize(code, 2), SABipartite(sc_target=30, max_group_size=50));

julia> OMEinsum.timespace_complexity(code, uniformsize(code, 2))
(200.0, 0.0)

julia> OMEinsum.timespace_complexity(optcode_kahypar, uniformsize(code, 2))
(38.0290167456887, 26.0)

julia> OMEinsum.timespace_complexity(optcode_sa, uniformsize(code, 2))
(34.86528023060411, 27.0)

julia> tc, sc = OMEinsum.timespace_complexity(optcode_tree, uniformsize(code, 2))
(30.541894421918297, 26.0)
codecov[bot] commented 3 years ago

Codecov Report

Merging #16 (426e129) into master (1049e6a) will decrease coverage by 0.50%. The diff coverage is 90.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #16      +/-   ##
==========================================
- Coverage   95.13%   94.62%   -0.51%     
==========================================
  Files           5        6       +1     
  Lines         493      540      +47     
==========================================
+ Hits          469      511      +42     
- Misses         24       29       +5     
Impacted Files Coverage Δ
src/treesa.jl 94.20% <66.66%> (+0.02%) :arrow_up:
src/interfaces.jl 87.50% <87.50%> (ø)
src/simplify.jl 94.64% <91.17%> (-5.36%) :arrow_down:
src/OMEinsumContractionOrders.jl 100.00% <100.00%> (ø)
src/kahypar.jl 93.52% <100.00%> (-0.05%) :arrow_down:
src/sa.jl 97.45% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1049e6a...426e129. Read the comment docs.