-
-
Notifications
You must be signed in to change notification settings - Fork 39
way faster constructor #157
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #157 +/- ##
==========================================
+ Coverage 76.62% 76.93% +0.31%
==========================================
Files 20 20
Lines 586 594 +8
==========================================
+ Hits 449 457 +8
Misses 137 137
Help us with your feedback. Take ten seconds to tell us how you rate us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This had been something I've been wanting to figure out for a while. I have a few minor requests for changes.
|
The current method of creating a component array from a nested dict is a little strange, I think it's better to convert the dict into a named tuple first. EDIT: just treat dicts like named tuples |
|
New benchmark julia> @benchmark ComponentArray(a = $data_1, b = $data_2)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 9.600 μs … 4.390 ms ┊ GC (min … max): 0.00% … 99.16%
Time (median): 15.950 μs ┊ GC (median): 0.00%
Time (mean ± σ): 20.259 μs ± 97.878 μs ┊ GC (mean ± σ): 13.10% ± 2.95%
▂▇█▅▅▅▅▇▇▇▆▄▃▁▁ ▁▁▁▁ ▁▁▁▂▁ ▂
███████████████████▇█▇▇▇████████████████▆▅▅▄▄▄▃▅▅▅▇▆▆▆▅▇▆▅▆ █
9.6 μs Histogram: log(frequency) by time 59.6 μs <
Memory estimate: 42.25 KiB, allocs estimate: 43. |
|
This change seems to have broken https://github.com/avik-pal/Lux.jl/runs/7702517164?check_suite_focus=true. @jonniedie could we add a downstream test dep on Lux similar to https://github.com/avik-pal/Lux.jl/blob/main/.github/workflows/Downstream.yml? |
|
You have some overloading there, I think it's time to upstream them instead. |
|
@avik-pal yeah, that’s a good idea. And it would also be a good idea to upstream whatever Lux is overloading as well. |
|
I will do it. This line is very domain specific @avik-pal, it could cause strange behaviour. Not so sure what is the motivation of it. julia> ComponentArray(a=Int[], b=(;))
ComponentVector{Float32}(a = Float32[], b = Float32[])
julia> ComponentArray(a=Int[1], b=(;))
ComponentVector{Int64}(a = [1], b = Int64[]) |
|
I think at some point it would lead to a |
|
Not sure if this PR would satisfy your requirement |
|
Yeah it should do it LuxDL/Lux.jl#126 |
Maybe I misunderstood,
reducelooks like it's for restoring the type. If the type is determined at the beginning, then there is no need to callreduce.