opt-einsum-torch
There have been many implementations of Einstein's summation. numpy's
numpy.einsum is the least efficient one as it only runs in single thread on
CPU. PyTorch's torch.einsum works for both CPU and CUDA tensors. However,
since there is no virtual CUDA memory, torch.einsum will run out of CUDA
memory for large tensors.
This code aims at implementing a memory-efficient einsum function using
PyTorch as the backend. This code also uses the opt_einsum package to
optimizes the contraction path to achieve the minimal FLOPS.
Usage
from opt_einsum_torch import EinsumPlanner
import torch
# Some huge tensors
arr1, arr2 = ..., ...
ee = EinsumPlanner(torch.device('cuda:0'), cuda_mem_limit=0.9)
result = ee.einsum('ijk,jkl->il', arr1, arr2)
The resulting tensor result will be a PyTorch CPU tensor. You could convert
it into numpy array by simply calling result.numpy().
Future works
- Support multiple GPUs.
- Memory efficient einsum kernels.
- CUDA data transfer profilers.
Metadata
Release files for opt-einsum-torch 0.1.0
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 |
|---|---|---|---|---|
| opt-einsum-torch-0.1.0.tar.gz | 10.0 kB | Without provenance | Details for opt-einsum-torch-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opt_einsum_torch-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for opt_einsum_torch-0.1.0-py3-none-any.whl |
Total release size: 20.2 kB
Release files / opt-einsum-torch-0.1.0.tar.gz
| Download URL | opt-einsum-torch-0.1.0.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
feeae21ea0ff6427c3095c3361e9444b0df70ebaaf0c985e47cf728fe4129c45
|
|
BLAKE2b-256 checksum How to use checksums |
dbaef092ce0cb43ad33099a1a5ecce1acb3b7a8d480ccf7af9c618da691696a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
|
Release files / opt_einsum_torch-0.1.0-py3-none-any.whl
| Download URL | opt_einsum_torch-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f784f9f9b4df402ea08a0e2037787b9c44809bd5bd3b9f366d3ae78f553990f
|
|
BLAKE2b-256 checksum How to use checksums |
5cd7bf9a3d615cf0ed11b24eec4ce6f31bc4f1717c07818174c3eaaf951b272c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
|
Security for opt-einsum-torch 0.1.0
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.