NumPy-style histograms in PyTorch
Project description
NumPy-style histograms in PyTorch
The torchist package implements NumPy's histogram and histogramdd functions in PyTorch with CUDA support. The package also features implementations of ravel_multi_index, unravel_index and some useful functionals like entropy or kl_divergence.
Installation
The torchist package is available on PyPI, which means it is installable with pip.
pip install torchist
Alternatively, if you need the latest features, you can install it from the repository.
pip install git+https://github.com/francois-rozet/torchist
Getting Started
import torch
import torchist
x = torch.rand(100, 3).cuda()
hist = torchist.histogramdd(x, bins=10, low=0.0, upp=1.0)
print(hist.shape) # (10, 10, 10)
Benchmark
The implementations of torchist are on par or faster than those of numpy and torch on CPU. On GPU (CUDA), they are much faster.
$ torchist-benchmark
CPU
---
np.histogram 0.8917 s
np.histogram (edges) 0.5993 s
np.histogramdd 16.8441 s
np.histogramdd (edges) 13.7680 s
torch.histogram 0.3251 s
torch.histogram (edges) 0.4217 s
torch.histogramdd 1.0528 s
torch.histogramdd (edges) 1.1955 s
torchist.histogram 0.4250 s
torchist.histogram (edges) 0.6372 s
torchist.histogramdd 1.6266 s
torchist.histogramdd (edges) 3.8619 s
CUDA
----
torchist.histogram 0.1045 s
torchist.histogram (edges) 0.0672 s
torchist.histogramdd 0.0906 s
torchist.histogramdd (edges) 0.1170 s
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torchist-1.0.1.tar.gz.
File metadata
- Download URL: torchist-1.0.1.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c5533ce07c3f35bcf23b2c03c2378bf132df2a59004cd529ffbf840137e12a5
|
|
| MD5 |
54456790710632309ee3fc04dbfc4258
|
|
| BLAKE2b-256 |
5ed90dc9c395bd9957318f7a65de9fdbf16142cc2ab16a87f718db229f4c69dd
|
File details
Details for the file torchist-1.0.1-py3-none-any.whl.
File metadata
- Download URL: torchist-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92eeca41c4dc5c3426eb61f3567e261935770bb6d06eb26a562e051083b7c480
|
|
| MD5 |
e07f64ae37f08fba470537af8fa7915f
|
|
| BLAKE2b-256 |
6c9dc34a447947d291e691fa48c9615274a5fc92caaef46665528ca8a296ccb7
|