Overview
AnyGrad is a simple tensor library that makes it easy to perform forward and backward passes. It uses a high-performance C++ backend together with a user-friendly Python frontend. You can change the backend easily and simply.
Note: currently version
0.0.1does not support any engine. But in the future, the integrations of engines likenumpy,pytorchetc. will come and you can use them for anything from Tensor operation to high-level transformer training.
Installation
Install the library from PyPI:
pip install anygrad
If you'd like to work on the code:
git clone https://github.com/Ruhaan838/AnyGrad.git
./setup.sh
Getting Started
Creating a Tensor
Create tensors by importing the library and instantiating Tensor. By default, gradients are not tracked unless you enable them:
import anygrad
# A tensor that does not calculate gradients
a = anygrad.Tensor([1, 2, 3])
# A tensor with gradient tracking enabled
b = anygrad.Tensor([2, 3, 4], requires_grad=True)
# A tensor with a specific data type (float64)
c = anygrad.Tensor([2, 3, 4], dtype=anygrad.float64)
Other datatypes:
anygrad.int32
anygrad.int64
anygrad.bool
Arithmetic Operations
Element-wise Operations
Perform calculations on tensors element by element:
d = a + b # addition
d = a * d # multiplication
d = d / 10 # division
e = d - 10 # subtraction
Matrix Multiplication
You can multiply matrices in two ways:
# Using the @ operator:
a = anygrad.ones((1, 2, 3), requires_grad=True)
b = anygrad.ones((2, 3, 4), requires_grad=True)
c = a @ b # tensor of shape (2, 2, 4)
# Or using the function:
c = anygrad.matmul(a, b)
Gradient Calculation
AnyGrad automatically computes gradients, which you can access after running the backward pass:
a = anygrad.Tensor([1, 2, 3], requires_grad=True)
b = anygrad.Tensor([2, 3, 4], requires_grad=True)
c = a * b
result = c.sum()
result.backward()
print(a.grad)
print(b.grad)
Contributing
Contributions are welcome! Whether you want to improve performance or enhance the documentation, please open an issue or submit a pull request.
License
This project is licensed under the terms outlined in the LICENSE file.
Metadata
Release files for anygrad 0.0.4
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 | |
|---|---|---|---|---|
| anygrad-0.0.4.tar.gz | 31.3 kB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| anygrad-0.0.4-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| anygrad-0.0.4-cp313-cp313-win32.whl | CPython 3.13 | CPython 3.13 | Windows x86-32 | Details |
| anygrad-0.0.4-cp313-cp313-macosx_10_14_universal2.whl | CPython 3.13 | CPython 3.13 | macOS 10.14+ universal2 (ARM64, x86-64) | Details |
| anygrad-0.0.4-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| anygrad-0.0.4-cp312-cp312-win32.whl | CPython 3.12 | CPython 3.12 | Windows x86-32 | Details |
| anygrad-0.0.4-cp312-cp312-macosx_10_14_universal2.whl | CPython 3.12 | CPython 3.12 | macOS 10.14+ universal2 (ARM64, x86-64) | Details |
| anygrad-0.0.4-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| anygrad-0.0.4-cp311-cp311-win32.whl | CPython 3.11 | CPython 3.11 | Windows x86-32 | Details |
| anygrad-0.0.4-cp311-cp311-macosx_10_14_universal2.whl | CPython 3.11 | CPython 3.11 | macOS 10.14+ universal2 (ARM64, x86-64) | Details |
| anygrad-0.0.4-cp310-cp310-win_amd64.whl | CPython 3.10 | CPython 3.10 | Windows x86-64 | Details |
| anygrad-0.0.4-cp310-cp310-win32.whl | CPython 3.10 | CPython 3.10 | Windows x86-32 | Details |
| anygrad-0.0.4-cp310-cp310-macosx_10_14_universal2.whl | CPython 3.10 | CPython 3.10 | macOS 10.14+ universal2 (ARM64, x86-64) | Details |
| anygrad-0.0.4-cp39-cp39-win_amd64.whl | CPython 3.9 | CPython 3.9 | Windows x86-64 | Details |
| anygrad-0.0.4-cp39-cp39-win32.whl | CPython 3.9 | CPython 3.9 | Windows x86-32 | Details |
| anygrad-0.0.4-cp39-cp39-macosx_10_14_universal2.whl | CPython 3.9 | CPython 3.9 | macOS 10.14+ universal2 (ARM64, x86-64) | Details |
Total release size: 6.8 MB
Release files / anygrad-0.0.4.tar.gz
| Download URL | anygrad-0.0.4.tar.gz |
|---|---|
| Size | 31.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be5fe8c80932db90d88f7440c48e58948df163a434fe66e281f18791c979a544
|
|
BLAKE2b-256 checksum How to use checksums |
972899402b0ec00a475e4146a9737cacec40c0fbd28b4c8b0f5a7ac7e967617b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp313-cp313-win_amd64.whl
| Download URL | anygrad-0.0.4-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 308.5 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
de95a5d8e0a9a56c24babc0b1400bbdfcb80664860ef9c568b57ddb25de64938
|
|
BLAKE2b-256 checksum How to use checksums |
72df05db1b296a0055ac7512c7396ea72baa616bd659641bddb34dfe7f25cd80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp313-cp313-win32.whl
| Download URL | anygrad-0.0.4-cp313-cp313-win32.whl |
|---|---|
| Size | 262.1 kB |
| Tags | CPython 3.13 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
c27f92d2bb2813d414d428a312f2d124e934c0d5e47887d23392fefa8225d5f6
|
|
BLAKE2b-256 checksum How to use checksums |
85d2835f5c3b006e9d6d3b4b8b32203a46413d339568c0f357a40733838fbbf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp313-cp313-macosx_10_14_universal2.whl
| Download URL | anygrad-0.0.4-cp313-cp313-macosx_10_14_universal2.whl |
|---|---|
| Size | 784.7 kB |
| Tags | CPython 3.13 macOS 10.14+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
934dfed0aa398335d6a467458ab52504a4f224ebb94295034a8ce95d479ab26f
|
|
BLAKE2b-256 checksum How to use checksums |
23972e11b7170bba9db8c0fe26075e72ea62e6002ead1ce00c97cee3067d2ab1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp312-cp312-win_amd64.whl
| Download URL | anygrad-0.0.4-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 308.4 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
61ccd24cb7ac08c7a0c64bcae3babaa66e2b5a621c37e28d0f9e1739f9c2fcee
|
|
BLAKE2b-256 checksum How to use checksums |
1b3f85ce659abf3bdab4329b535033ac77db315723b973bd05a55543b9484bcf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp312-cp312-win32.whl
| Download URL | anygrad-0.0.4-cp312-cp312-win32.whl |
|---|---|
| Size | 262.3 kB |
| Tags | CPython 3.12 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
53754a65574ecfb8d8740ea6d475e720fc6a097b64a0e2e7cc96ba77945e57d2
|
|
BLAKE2b-256 checksum How to use checksums |
8d6d10d8246be1bf9b613d4fee934a51b9662a7e42b08abe5ecedb99d28779b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp312-cp312-macosx_10_14_universal2.whl
| Download URL | anygrad-0.0.4-cp312-cp312-macosx_10_14_universal2.whl |
|---|---|
| Size | 784.3 kB |
| Tags | CPython 3.12 macOS 10.14+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
8f1fe71da4cee5ffe26e5c52362aba65ae823adb293e5bf62b4bf0438f389b9b
|
|
BLAKE2b-256 checksum How to use checksums |
b75151ff9221daae814aefeeb17fed4f27573ca6d943fe4e9cd6beeb96570031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp311-cp311-win_amd64.whl
| Download URL | anygrad-0.0.4-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 306.2 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d6b51620a2a1a462c4ed649878c39ad2d2f52973e94bfd3032657e8f9c699123
|
|
BLAKE2b-256 checksum How to use checksums |
0b8bb76ee19102d7c72a900e085130a0d5d862a1b081ef53ed6ff4c28c0630a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp311-cp311-win32.whl
| Download URL | anygrad-0.0.4-cp311-cp311-win32.whl |
|---|---|
| Size | 263.1 kB |
| Tags | CPython 3.11 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
4c721bd9c1583ff13076f5db039936e4ba80bf79f2526920376dbf5a82d6678e
|
|
BLAKE2b-256 checksum How to use checksums |
377797c426a1c72e4cdf9b655f57f393b15f13faff19a13a2062db6df2162a27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp311-cp311-macosx_10_14_universal2.whl
| Download URL | anygrad-0.0.4-cp311-cp311-macosx_10_14_universal2.whl |
|---|---|
| Size | 781.5 kB |
| Tags | CPython 3.11 macOS 10.14+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
e9a9b93f45102aecf3ad87bd02233e4e351a3bd675a9a0512e853768f71d0e04
|
|
BLAKE2b-256 checksum How to use checksums |
87b0262dfb7cd1e8f58b2afd484cebaf8ee38000e278aa862a8b2d27e063fedd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp310-cp310-win_amd64.whl
| Download URL | anygrad-0.0.4-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 303.9 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
010559a263fbdcbc624026946658b14f3abb623144b49e7d1127004bb268b105
|
|
BLAKE2b-256 checksum How to use checksums |
bb0809c1c2ddef3593fba76a172b3a27aebb4d69862882fdbf80df9b0b2fb245
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp310-cp310-win32.whl
| Download URL | anygrad-0.0.4-cp310-cp310-win32.whl |
|---|---|
| Size | 261.2 kB |
| Tags | CPython 3.10 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
05ec7a99fe0977fbbc9eb4422a82a8c4ac1aebf90bff558de1f6c349786bf547
|
|
BLAKE2b-256 checksum How to use checksums |
45a17b76ffcb5b65afcfafdf48d4c6b4615c3eaf81547abe73efd388f8e729b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp310-cp310-macosx_10_14_universal2.whl
| Download URL | anygrad-0.0.4-cp310-cp310-macosx_10_14_universal2.whl |
|---|---|
| Size | 774.0 kB |
| Tags | CPython 3.10 macOS 10.14+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
77f7a9eaebb1f89f5f3f253e383e0908e7b98e01b3146a2b0d1345c1203aa142
|
|
BLAKE2b-256 checksum How to use checksums |
63dd0152521d0d0806f6d80ac1588c6b7dd1a1625f8175aa35574b4a4877631d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp39-cp39-win_amd64.whl
| Download URL | anygrad-0.0.4-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 293.4 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c4994e1edb3495bd6b7e8b2f077ae1b33a2d6507d6d2b0632c9c00ab850055c2
|
|
BLAKE2b-256 checksum How to use checksums |
559cf16f3d10511831cb02f87aba680f3aaae0198bcc037f8b40e33854cae660
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp39-cp39-win32.whl
| Download URL | anygrad-0.0.4-cp39-cp39-win32.whl |
|---|---|
| Size | 261.4 kB |
| Tags | CPython 3.9 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
b9c6011386a65a1893e648c4595177b634496fc02bf7e7ebe48256d725b71ec3
|
|
BLAKE2b-256 checksum How to use checksums |
2c46ef60166b230d2f09da3b46faac7376b51c14cc6c6f27668b360974b6b017
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / anygrad-0.0.4-cp39-cp39-macosx_10_14_universal2.whl
| Download URL | anygrad-0.0.4-cp39-cp39-macosx_10_14_universal2.whl |
|---|---|
| Size | 774.4 kB |
| Tags | CPython 3.9 macOS 10.14+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
d2137d83f1cca1b401447a7b4e0dcd749132fd0e9d4eba801e6085896080a257
|
|
BLAKE2b-256 checksum How to use checksums |
9cea16315f1852cda93fd42e71b528bd80b0fb9c5de03d445a8c3d939200b25f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for anygrad 0.0.4
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.