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
Metadata
Release files for torchist 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torchist-1.0.1.tar.gz | 9.5 kB | Without provenance | Details for torchist-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torchist-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for torchist-1.0.1-py3-none-any.whl |
Total release size: 18.0 kB
Release files / torchist-1.0.1.tar.gz
| Download URL | torchist-1.0.1.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c5533ce07c3f35bcf23b2c03c2378bf132df2a59004cd529ffbf840137e12a5
|
|
BLAKE2b-256 checksum How to use checksums |
5ed90dc9c395bd9957318f7a65de9fdbf16142cc2ab16a87f718db229f4c69dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / torchist-1.0.1-py3-none-any.whl
| Download URL | torchist-1.0.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92eeca41c4dc5c3426eb61f3567e261935770bb6d06eb26a562e051083b7c480
|
|
BLAKE2b-256 checksum How to use checksums |
6c9dc34a447947d291e691fa48c9615274a5fc92caaef46665528ca8a296ccb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Security for torchist 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.