Utility extensions for PyTorch
Project description
torchgear
Utility extensions for PyTorch: tensor math helpers, shape utilities, and nn.Module mixins for device/dtype consistency and parameter freezing.
Requirements
- Python 3.12+
- PyTorch 2.0+
Installation
pip install torchgear
Install from source:
git clone https://github.com/GjQAQ/torchgear.git
cd torchgear
pip install -e .
Quick start
import torch
import torchgear as tg
import torch.nn as nn
# Math helpers
z = torch.tensor([1 + 2j, 3 + 4j])
tg.abs2(z)
# Module base class
class MyModel(tg.TorchgearModule):
def __init__(self):
super().__init__()
self.w = nn.Parameter(torch.randn(4))
def forward(self, x):
return x @ self.w
model = MyModel()
model.freeze()
Documentation
Online documentation: https://gjqaq.github.io/torchgear/
API reference and guides are also in the docs/ directory. Build locally with uv (install uv first):
uv sync --group doc
cd docs && make html
Without uv, install sphinx and furo, then run make html in docs/.
Development
Requires uv (see link above to install):
uv sync --group test
pytest
Without uv, install pytest and run pytest from the project root.
License
MIT License. See LICENSE for details.
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 torchgear-0.1.0.tar.gz.
File metadata
- Download URL: torchgear-0.1.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84b553b729f91477d3664d6b27f2b07d0c683ddb5272e460225ddabdb04f4ed6
|
|
| MD5 |
d9468def981c9e9426582bb006f6d7e4
|
|
| BLAKE2b-256 |
1c2d5698d06d721f3ccf78af0277bd862300a026ef7441d6bcd64b6cc36f4d39
|
File details
Details for the file torchgear-0.1.0-py3-none-any.whl.
File metadata
- Download URL: torchgear-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c86448c23e66dec855b8555bbf9a406591243dbfb504a8ca6bce9442710cc739
|
|
| MD5 |
554ed9af7c9d214723a3e27f96fcb9c2
|
|
| BLAKE2b-256 |
ec6b87eb69bd1630bb2f1c15a33c8f4ade9b2ebc3af2d3fbbed25503cb04dc10
|