Skip to content
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

Vectorized sspd #26

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

galiwohlstadter
Copy link

Description:
Add vectorized implementation to the SSPD distance calculations: refrain from python for loops and take advantage of NumPy vectorized operations on ND-arrays to enhance performance.
NumPy functions work on numpy arrays and is tremendously faster due to the benefits of vectorization.
As can be seen in benchmark_sspd.csv, the Cython implementation (not changed) is ~20 times faster than the Python implementation. However, the new vectorized Python implementation is more than 11 times faster than the non-vectorized existing implementation.
So, this implementation is beneficial for those who'd rather use Python (and not Cython).

Files structure:
new files added under /traj_dist/pydist/:
basic_spherical_vectorized.py (vectorized version of basic_spherical.py)
sspd_spherical_vectorized.py (vectorized version of the spherical calculations in sspd.py)
Besides vectorized code version, some new functions (e.g s_pt_to_traj_dist) were added, due to our software needs (*can be removed, according to your preference)

Tests:
Added new test file /tests/sspd_tests.py, used to ensure code correctness by comparing to results recorded before any code changes were applied.
Recorded previous results can be found here: /data/benchmark_spherical_sspd_results.csv

Benchmark:
Updated the code and benchmark.csv results to include both the Cython and Python implementations (included solely the Cython benchmark before). Ran on computer: apple M1 pro, 16GB memory, macOS Monterey (12.6.1)

About myself and the project I'm working on:
This code extension was done as part of of my role @ Attenti
https://www.attentigroup.com/ now part of AlliedUniversal
The project I've been working on, was human movement (trajectory) prediction. The prediction model is a statistical one, and aimed to be used in Domestic Violence (DV) programs for early warning.
You are welcome to visit my linkedin page:
https://www.linkedin.com/in/gali-wohlstadter-6a101819/

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.

1 participant