semiring_torch
Run your pytorch code on any semiring with a single line of code! Semiring_torch is built on top of autoray.
Warning: this is a proof of concept. Expect bugs and missing features.
Example
By using the logarithmic semiring, you can easily write numerically stable code. In the following example, we compute a matrix product in log-space.
| Regular torch | semiring_torch |
|---|---|
import torch
x1 = torch.tensor([[0.1, 0.6], [0.1, 0.4]])
x2 = torch.tensor([[0.5, 0.3], [0.2, 0.1]])
x1 = x1.log()
x2 = x2.log()
result = x1[:, :, None] + x2[None, :, :]
result = torch.logsumexp(result, dim=1)
result = result.exp()
|
from autoray import numpy as torch
from semiring_torch import logarithmic_semiring
with logarithmic_semiring:
x1 = torch.tensor([[0.1, 0.6], [0.1, 0.4]])
x2 = torch.tensor([[0.5, 0.3], [0.2, 0.1]])
result = x1 @ x2
|
Supported semirings
Currently only the logarithmic semiring is supported, but more semirings can be added easily.
Metadata
Release files for semiring-torch 0.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 | |
|---|---|---|---|---|
| semiring_torch-0.0.1.tar.gz | 21.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| semiring_torch-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.6 kB
Release files / semiring_torch-0.0.1.tar.gz
| Download URL | semiring_torch-0.0.1.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
851face16ca2c7a2529665f6ceb9c824226ac7111d50bc2b748cd7dc57cfd228
|
|
BLAKE2b-256 checksum How to use checksums |
f0312bbc5a2107eb7398b1094a1335308ce0f7b6c0e53c9164bdcb35ccc74c8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / semiring_torch-0.0.1-py3-none-any.whl
| Download URL | semiring_torch-0.0.1-py3-none-any.whl |
|---|---|
| Size | 28.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
563769309478503cfb8b57cac8b6cbbe66e58b2cf2118414ba3a5d89c2e90f73
|
|
BLAKE2b-256 checksum How to use checksums |
fa58bdaa399d0c34524683031df7034257b11e815a9485776affc34b4813775a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for semiring-torch 0.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.