Fast discounted cumulative sums in PyTorch
Project description
This package implements an efficient parallel algorithm for the computation of discounted cumulative sums
with differentiable bindings to PyTorch. The cumsum
operation is frequently seen in data science
domains concerned with time series, including Reinforcement Learning (RL).
The traditional sequential algorithm performs the computation of the output elements in a loop. For an input of size
N
, it requires O(N)
operations and takes O(N)
time steps to complete.
The proposed parallel algorithm requires a total of O(N log N)
operations, but takes only O(log N)
time, which is a
considerable trade-off in many applications involving large inputs.
Features of the parallel algorithm:
- Speed logarithmic in the input size
- Better numerical precision than sequential algorithms
Features of the package:
- CPU: sequential algorithm in C++
- GPU: parallel algorithm in CUDA
- Gradients computation for input and gamma
- Batch support for input and gamma
- Both left and right directions of summation supported
- PyTorch bindings
Find more details and the most up-to-date information on the project webpage: https://www.github.com/toshas/torch-discounted-cumsum
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file torch_discounted_cumsum-1.1.0.tar.gz
.
File metadata
- Download URL: torch_discounted_cumsum-1.1.0.tar.gz
- Upload date:
- Size: 185.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34e6a7e10f416a7aa84e5fb4e00d6a84a0cfbb0a68bcf22a3434488360f0ea37 |
|
MD5 | 690b2c48b523f7d09ea66e40d870dee6 |
|
BLAKE2b-256 | f5af9e9afa05c919429c09289237134d7e053e0110363939c5acf077c30079dd |