-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hail] Introduce
ArrayFold2
to permit more deforesting (#6981)
* [hail] Introduce `ArrayFold2` to permit more deforesting Problem 1: functions like `min`/`max` need to do a length check, preventing us from implementing them in a single primitive fold. Problem 2: functions like `mean` use a struct as the accumulator, leading to allocation (!) every element. Solution to both: make it possible to have multiple primitive accumulators. This is `ArrayFold2`. The node is different from `ArrayFold` in that it: * has as sequence of accumulators, not just one * has a sequence of seq ops, one for each accumulator. Each of these sequence ops can see all the accumulators, and will see the updated value from sequence operations with a smaller index. * has a result op, which is a function from accumulators to result. By changing `min`/`max` to use ArrayFold2 and inlining these functions, we can get a reasonable speedup on `split_multi_hts`: #6980 (this PR's parent): ``` 2019-09-03 07:11:16,374: INFO: burn in: 42.33s 2019-09-03 07:11:56,085: INFO: run 1: 39.71s 2019-09-03 07:12:34,916: INFO: run 2: 38.83s 2019-09-03 07:13:14,087: INFO: run 3: 39.17s ``` PR: ``` 2019-09-03 07:32:10,416: INFO: burn in: 38.03s 2019-09-03 07:32:39,237: INFO: run 1: 28.82s 2019-09-03 07:33:07,778: INFO: run 2: 28.50s 2019-09-03 07:33:35,997: INFO: run 3: 28.21s ``` * mean benchmarks * Ported `ArrayFunctions.mean` to ArrayFold2. Benchmark: ```python @benchmark def table_range_means(): ht = hl.utils.range_table(10_000_000, 16) ht = ht.annotate(m = hl.mean(hl.range(0, ht.idx % 1111))) ht._force_count() ``` Master: ``` 2019-09-03 09:39:05,777: INFO: [1/1] Running table_range_means... 2019-09-03 09:40:52,557: INFO: burn in: 106.78s 2019-09-03 09:42:34,333: INFO: run 1: 101.78s 2019-09-03 09:44:14,982: INFO: run 2: 100.65s 2019-09-03 09:45:53,590: INFO: run 3: 98.61s ``` PR: ``` 2019-09-03 09:47:26,110: INFO: [1/1] Running table_range_means... 2019-09-03 09:47:29,465: INFO: burn in: 3.35s 2019-09-03 09:47:32,615: INFO: run 1: 3.15s 2019-09-03 09:47:35,703: INFO: run 2: 3.09s 2019-09-03 09:47:38,840: INFO: run 3: 3.14s ``` * add back in arrayfor * add interpret rule * add interpret rule * fix * remove unused var * bump!
- Loading branch information
Showing
24 changed files
with
234 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.