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
This adds a new variant reduce_accumulate2 using the scan with an associative operator that is slower in a single-threaded context but can take full advantage of parallel scan implementations.
Copy file name to clipboardExpand all lines: README.md
+11-8Lines changed: 11 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,8 @@ More precisely,
18
18
1.[`branchless`](fast_frechet/branchless.py): A variant w/o branches.
19
19
1.[`linear_memory`](fast_frechet/linear_memory.py): This formulation reduces the quadratic memory footprint to a linear one.
20
20
1.[`accumulate`](fast_frechet/accumulate.py): Formulation using a scan operation.
21
-
1.[`reduce_accumulate`](fast_frechet/reduce_accumulate.py): Formulation using a fold operation.
21
+
1.[`reduce_accumulate`](fast_frechet/reduce_accumulate.py): Formulation using scan and fold operations.
22
+
1.[`reduce_accumulate2`](fast_frechet/reduce_accumulate2.py): Alternative formulation using the scan with an associative operator that is slower in a single-threaded context but can take full advantage of parallel scan implementations.
22
23
1.[`compiled`](fast_frechet/compiled.py): Variant of [`reduce_accumulate`](fast_frechet/reduce_accumulate.py) using the [Numba library](https://numba.pydata.org/) for JIT compilation of the innermost loop.
23
24
24
25
Implementations of all these variants can be found under [`fast_frechet/`](fast_frechet/) or by simply clicking on the listed names above.
@@ -40,6 +41,7 @@ $ pre-commit install
40
41
The snippet below estimates the Fréchet distance between the polygonal curves `p` and `q` using the Euclidean distance as a metric to measure distances between points:
@@ -55,13 +57,14 @@ For invoking the [benchmark script](fast_frechet/__main__.py), run:
55
57
$ python fast_frechet
56
58
Length of trajectory = 1024
57
59
58
-
no_recursion: 2303 ms
59
-
vectorized: 553 ms
60
-
branchless: 508 ms
61
-
linear_memory: 348 ms
62
-
accumulate: 286 ms
63
-
reduce_accumulate: 282 ms
64
-
compiled: 11 ms
60
+
no_recursion: 1915 ms
61
+
vectorized: 495 ms
62
+
branchless: 466 ms
63
+
linear_memory: 294 ms
64
+
accumulate: 258 ms
65
+
reduce_accumulate: 249 ms
66
+
reduce_accumulate2: 360 ms
67
+
compiled: 9 ms
65
68
```
66
69
(Note that we don't even try to benchmark the [`vanilla`](fast_frechet/vanilla.py) version here, as it already crashes for polygonal curves with a few hundred points due to its recursive nature.)
0 commit comments