Installation
$ pip install torch_fn
Usage
from torch_fn import torch_fn
import numpy as np
import torch.nn.functional as F
@torch_fn
def torch_softmax(*args, **kwargs):
return F.softmax(*args, **kwargs)
def custom_print(x):
print(type(x), x)
# Test the decorator with different input types
x = [1, 2, 3]
x_list = x
x_tensor = torch.tensor(x).float()
x_tensor_cuda = torch.tensor(x).float().cuda()
x_array = np.array(x)
x_df = pd.DataFrame({"col1": x})
custom_print(torch_softmax(x_list, dim=-1))
# /home/ywatanabe/proj/torch_fn/src/torch_fn/_torch_fn.py:57: UserWarning: Converted from <class 'list'> to <class 'torch.Tensor'> (cuda:0)
# warnings.warn(
# <class 'numpy.ndarray'> [0.09003057 0.24472848 0.6652409 ]
custom_print(torch_softmax(x_array, dim=-1))
# /home/ywatanabe/proj/torch_fn/src/torch_fn/_torch_fn.py:57: UserWarning: Converted from <class 'numpy.ndarray'> to <class 'torch.Tensor'> (cuda:0)
# warnings.warn(
# <class 'numpy.ndarray'> [0.09003057 0.24472848 0.6652409 ]
custom_print(torch_softmax(x_df, dim=-1))
# /home/ywatanabe/proj/torch_fn/src/torch_fn/_torch_fn.py:49: UserWarning: Converted from <class 'pandas.core.frame.DataFrame'> to <class 'torch.Tensor'> (cuda:0)
# warnings.warn(
# <class 'numpy.ndarray'> [0.09003057 0.24472848 0.6652409 ]
custom_print(torch_softmax(x_tensor, dim=-1))
# <class 'torch.Tensor'> tensor([0.0900, 0.2447, 0.6652])
custom_print(torch_softmax(x_tensor_cuda, dim=-1))
# <class 'torch.Tensor'> tensor([0.0900, 0.2447, 0.6652], device='cuda:0')
Metadata
Release files for torch-fn 1.0.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 | |
|---|---|---|---|---|
| torch_fn-1.0.0.tar.gz | 4.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| torch_fn-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / torch_fn-1.0.0.tar.gz
| Download URL | torch_fn-1.0.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b817d63e8fdcce403173033d90f0f3da72384b4db77654dbc2716de2e0bc2075
|
|
BLAKE2b-256 checksum How to use checksums |
c91375bdfa2b2bd107d696f6c68451881f18179e3c0f4cbf4b4e1dd0436bc7f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / torch_fn-1.0.0-py3-none-any.whl
| Download URL | torch_fn-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b20ce51c43839eca24fde8bd665f64d98b9e1cb4a641240045a641c7ec24195
|
|
BLAKE2b-256 checksum How to use checksums |
1f2c0c7b26b0a4f7df134c7bb74d9fa72e4b1cf8f9b969871bc31bbc189d26d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for torch-fn 1.0.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.