Skip to content

fix tree construction for large number of nodes #65

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

Merged
merged 2 commits into from
Jun 13, 2019

Conversation

GiggleLiu
Copy link
Contributor

fix #63

julia> using TensorOperations: BinaryTreeNode
julia> const order = (7, 14, 13, 5, 56,
           25, 26, 58, 29, 57,
           4, 44, 36, 35, 43, 3, 21, 33, 34, 22,
           50, 38, 37, 49, 6, 31, 45, 46, 32, 8,
           47, 54, 55, 48, 12, 16, 40, 39, 15, 10,
           1, 41, 19, 17, 18, 20, 42, 2, 60, 28, 52, 30, 51, 27, 59,
           9, 23, 24, 11, 53)

julia> order2tree(order) = length(order) == 1 ? order[1] : BinaryTreeNode(order2tree(order[1:end-1]), order[end])
order2tree (generic function with 1 method)

julia> tree = order2tree(order)
Contraction Tree: (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((7  14)  13)  5)  56)  25)  26)  58)  29)  57)  4)  44)  36)  35)  43)  3)  21)  33)  34)  22)  50)  38)  37)  49)  6)  31)  45)  46)  32)  8)  47)  54)  55)  48)  12)  16)  40)  39)  15)  10)  1)  41)  19)  17)  18)  20)  42)  2)  60)  28)  52)  30)  51)  27)  59)  9)  23)  24)  11)  53)

@GiggleLiu
Copy link
Contributor Author

I change the Tuple to BinaryTreeNode to make the type tree simpler.

According to my benchmark, the runtime performance is not decreased, while the compling stage performance is increased significantly. Could you please have a double check? @Jutho

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 76.288% when pulling 26e5282 on GiggleLiu:fixtree into 5283953 on Jutho:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 76.288% when pulling 26e5282 on GiggleLiu:fixtree into 5283953 on Jutho:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 76.288% when pulling 26e5282 on GiggleLiu:fixtree into 5283953 on Jutho:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 76.288% when pulling 26e5282 on GiggleLiu:fixtree into 5283953 on Jutho:master.

@coveralls
Copy link

coveralls commented Jun 3, 2019

Coverage Status

Coverage decreased (-0.4%) to 76.389% when pulling 0013403 on GiggleLiu:fixtree into 5283953 on Jutho:master.

@codecov
Copy link

codecov bot commented Jun 3, 2019

Codecov Report

Merging #65 into master will decrease coverage by 0.61%.
The diff coverage is 21.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #65      +/-   ##
==========================================
- Coverage   79.78%   79.17%   -0.62%     
==========================================
  Files          13       14       +1     
  Lines        1390     1402      +12     
==========================================
+ Hits         1109     1110       +1     
- Misses        281      292      +11
Impacted Files Coverage Δ
src/indexnotation/optimaltree.jl 93.82% <66.66%> (ø) ⬆️
src/indexnotation/binarytree.jl 9.09% <9.09%> (ø)
src/implementation/lrucache.jl 79.06% <0%> (-0.62%) ⬇️

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 5283953...26e5282. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 3, 2019

Codecov Report

Merging #65 into master will decrease coverage by 0.52%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #65      +/-   ##
==========================================
- Coverage   79.78%   79.25%   -0.53%     
==========================================
  Files          13       14       +1     
  Lines        1390     1403      +13     
==========================================
+ Hits         1109     1112       +3     
- Misses        281      291      +10
Impacted Files Coverage Δ
src/indexnotation/binarytree.jl 25% <25%> (ø)
src/indexnotation/optimaltree.jl 93.82% <66.66%> (ø) ⬆️
src/implementation/lrucache.jl 79.06% <0%> (-0.62%) ⬇️

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 5283953...0013403. Read the comment docs.

@Jutho
Copy link
Owner

Jutho commented Jun 3, 2019

Thanks; I'll take a look asap.

@GiggleLiu
Copy link
Contributor Author

The test coverage is decreased, since I wrote some untested printing functions for BinaryTreeNode. Should I add some test to show the printing does not throw an error?

@GiggleLiu
Copy link
Contributor Author

Here is a using case for testing

julia> using TensorOperations

julia> using Random, BenchmarkTools

julia> Random.seed!(2);

julia> net = ((11, 17), (2, 20), (15, 28, 38), (15, 21, 34), (12, 21, 40), (10, 30), (16, 22, 32),
           (13, 22, 38), (12, 20), (2, 27, 33), (5, 16, 37), (3, 26, 40), (6, 24), (14, 24, 36),
            (9, 18, 37), (1, 19, 31), (8, 26), (11, 23), (6, 17, 39), (14, 19, 36), (13, 30),
             (4, 25, 33), (7, 23, 39), (4, 28), (5, 27, 32), (9, 25, 35), (8, 29), (10, 18, 31),
              (7, 29, 35), (1, 3, 34));

julia> unique_tokens = union(net...);

julia> c = Dict(token=>TensorOperations.Power{:χ}(1,1) for token in unique_tokens)
Dict{Int64,TensorOperations.Power{,Int64}} with 40 entries:
  33 => χ
  18 => χ
  1  => χ
  32 => χ
  2  => χ
  40 => χ
  16 => χ
  11 => χ
    => 

julia> @benchmark TensorOperations.optimaltree(net, c)
BenchmarkTools.Trial: 
  memory estimate:  227.23 KiB
  allocs estimate:  2944
  --------------
  minimum time:     210.654 μs (0.00% GC)
  median time:      217.766 μs (0.00% GC)
  mean time:        279.853 μs (14.19% GC)
  maximum time:     62.270 ms (99.48% GC)
  --------------
  samples:          10000
  evals/sample:     1

@Jutho
Copy link
Owner

Jutho commented Jun 13, 2019

This looks good; thanks. I'll merge it and tag a new release.

@Jutho Jutho merged commit 4927ee1 into Jutho:master Jun 13, 2019
@Jutho
Copy link
Owner

Jutho commented Jun 13, 2019

New version 1.1.0 is up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The performance of optimaltree
3 participants