Skip to main content

A Tensor module that allows a deep learning framework to switch seamlessly between different engines.

Project description

🚂 AnyGrad: Flexible Engine for Tensor and Neural Network.

Python Version PyPI Version

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.1 does not support any engine. But in the future, the integrations of engines like numpy, pytorch etc. 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anygrad-0.0.4.tar.gz (31.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

anygrad-0.0.4-cp313-cp313-win_amd64.whl (308.5 kB view details)

Uploaded CPython 3.13Windows x86-64

anygrad-0.0.4-cp313-cp313-win32.whl (262.1 kB view details)

Uploaded CPython 3.13Windows x86

anygrad-0.0.4-cp313-cp313-macosx_10_14_universal2.whl (784.7 kB view details)

Uploaded CPython 3.13macOS 10.14+ universal2 (ARM64, x86-64)

anygrad-0.0.4-cp312-cp312-win_amd64.whl (308.4 kB view details)

Uploaded CPython 3.12Windows x86-64

anygrad-0.0.4-cp312-cp312-win32.whl (262.3 kB view details)

Uploaded CPython 3.12Windows x86

anygrad-0.0.4-cp312-cp312-macosx_10_14_universal2.whl (784.3 kB view details)

Uploaded CPython 3.12macOS 10.14+ universal2 (ARM64, x86-64)

anygrad-0.0.4-cp311-cp311-win_amd64.whl (306.2 kB view details)

Uploaded CPython 3.11Windows x86-64

anygrad-0.0.4-cp311-cp311-win32.whl (263.1 kB view details)

Uploaded CPython 3.11Windows x86

anygrad-0.0.4-cp311-cp311-macosx_10_14_universal2.whl (781.5 kB view details)

Uploaded CPython 3.11macOS 10.14+ universal2 (ARM64, x86-64)

anygrad-0.0.4-cp310-cp310-win_amd64.whl (303.9 kB view details)

Uploaded CPython 3.10Windows x86-64

anygrad-0.0.4-cp310-cp310-win32.whl (261.2 kB view details)

Uploaded CPython 3.10Windows x86

anygrad-0.0.4-cp310-cp310-macosx_10_14_universal2.whl (774.0 kB view details)

Uploaded CPython 3.10macOS 10.14+ universal2 (ARM64, x86-64)

anygrad-0.0.4-cp39-cp39-win_amd64.whl (293.4 kB view details)

Uploaded CPython 3.9Windows x86-64

anygrad-0.0.4-cp39-cp39-win32.whl (261.4 kB view details)

Uploaded CPython 3.9Windows x86

anygrad-0.0.4-cp39-cp39-macosx_10_14_universal2.whl (774.4 kB view details)

Uploaded CPython 3.9macOS 10.14+ universal2 (ARM64, x86-64)

File details

Details for the file anygrad-0.0.4.tar.gz.

File metadata

  • Download URL: anygrad-0.0.4.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4.tar.gz
Algorithm Hash digest
SHA256 be5fe8c80932db90d88f7440c48e58948df163a434fe66e281f18791c979a544
MD5 45423b22aa26482b790cccdc168f4f8a
BLAKE2b-256 972899402b0ec00a475e4146a9737cacec40c0fbd28b4c8b0f5a7ac7e967617b

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 308.5 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 de95a5d8e0a9a56c24babc0b1400bbdfcb80664860ef9c568b57ddb25de64938
MD5 af059f641f495b0cd05092a1b3ff025b
BLAKE2b-256 72df05db1b296a0055ac7512c7396ea72baa616bd659641bddb34dfe7f25cd80

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp313-cp313-win32.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp313-cp313-win32.whl
  • Upload date:
  • Size: 262.1 kB
  • Tags: CPython 3.13, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 c27f92d2bb2813d414d428a312f2d124e934c0d5e47887d23392fefa8225d5f6
MD5 19ab60fa2758b0446f006cf276fd2e4d
BLAKE2b-256 85d2835f5c3b006e9d6d3b4b8b32203a46413d339568c0f357a40733838fbbf4

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp313-cp313-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for anygrad-0.0.4-cp313-cp313-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 934dfed0aa398335d6a467458ab52504a4f224ebb94295034a8ce95d479ab26f
MD5 52af051bef55e01fae3ccc2cbc0390b7
BLAKE2b-256 23972e11b7170bba9db8c0fe26075e72ea62e6002ead1ce00c97cee3067d2ab1

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 308.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 61ccd24cb7ac08c7a0c64bcae3babaa66e2b5a621c37e28d0f9e1739f9c2fcee
MD5 e98633ecda18c62bb4a9865271e0224a
BLAKE2b-256 1b3f85ce659abf3bdab4329b535033ac77db315723b973bd05a55543b9484bcf

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp312-cp312-win32.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp312-cp312-win32.whl
  • Upload date:
  • Size: 262.3 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 53754a65574ecfb8d8740ea6d475e720fc6a097b64a0e2e7cc96ba77945e57d2
MD5 2c30968a492fa7d20e080218bd1b87c6
BLAKE2b-256 8d6d10d8246be1bf9b613d4fee934a51b9662a7e42b08abe5ecedb99d28779b5

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp312-cp312-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for anygrad-0.0.4-cp312-cp312-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 8f1fe71da4cee5ffe26e5c52362aba65ae823adb293e5bf62b4bf0438f389b9b
MD5 91ee293c2170b3ef60f0dfec05240a27
BLAKE2b-256 b75151ff9221daae814aefeeb17fed4f27573ca6d943fe4e9cd6beeb96570031

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 306.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d6b51620a2a1a462c4ed649878c39ad2d2f52973e94bfd3032657e8f9c699123
MD5 369221fa9fab23d26b5d5119d244da5a
BLAKE2b-256 0b8bb76ee19102d7c72a900e085130a0d5d862a1b081ef53ed6ff4c28c0630a9

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp311-cp311-win32.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp311-cp311-win32.whl
  • Upload date:
  • Size: 263.1 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 4c721bd9c1583ff13076f5db039936e4ba80bf79f2526920376dbf5a82d6678e
MD5 4a323db774133253d80021ed7e1732e6
BLAKE2b-256 377797c426a1c72e4cdf9b655f57f393b15f13faff19a13a2062db6df2162a27

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp311-cp311-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for anygrad-0.0.4-cp311-cp311-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 e9a9b93f45102aecf3ad87bd02233e4e351a3bd675a9a0512e853768f71d0e04
MD5 7afaf1a2fea5d11c299c6b79122f323b
BLAKE2b-256 87b0262dfb7cd1e8f58b2afd484cebaf8ee38000e278aa862a8b2d27e063fedd

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 303.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 010559a263fbdcbc624026946658b14f3abb623144b49e7d1127004bb268b105
MD5 0737fc3a6ddafcd986993922b8c9d169
BLAKE2b-256 bb0809c1c2ddef3593fba76a172b3a27aebb4d69862882fdbf80df9b0b2fb245

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp310-cp310-win32.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp310-cp310-win32.whl
  • Upload date:
  • Size: 261.2 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 05ec7a99fe0977fbbc9eb4422a82a8c4ac1aebf90bff558de1f6c349786bf547
MD5 1f5a95234305aa7735b1fdd8c622f527
BLAKE2b-256 45a17b76ffcb5b65afcfafdf48d4c6b4615c3eaf81547abe73efd388f8e729b8

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp310-cp310-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for anygrad-0.0.4-cp310-cp310-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 77f7a9eaebb1f89f5f3f253e383e0908e7b98e01b3146a2b0d1345c1203aa142
MD5 a9d9b37e2c2f21debe407ac6bcc309ac
BLAKE2b-256 63dd0152521d0d0806f6d80ac1588c6b7dd1a1625f8175aa35574b4a4877631d

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 293.4 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c4994e1edb3495bd6b7e8b2f077ae1b33a2d6507d6d2b0632c9c00ab850055c2
MD5 b9a3e3cb2afaff37160b9fcbbeea97f9
BLAKE2b-256 559cf16f3d10511831cb02f87aba680f3aaae0198bcc037f8b40e33854cae660

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp39-cp39-win32.whl.

File metadata

  • Download URL: anygrad-0.0.4-cp39-cp39-win32.whl
  • Upload date:
  • Size: 261.4 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for anygrad-0.0.4-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 b9c6011386a65a1893e648c4595177b634496fc02bf7e7ebe48256d725b71ec3
MD5 cde4f430b24fe7ba61a5f9c30804d33f
BLAKE2b-256 2c46ef60166b230d2f09da3b46faac7376b51c14cc6c6f27668b360974b6b017

See more details on using hashes here.

File details

Details for the file anygrad-0.0.4-cp39-cp39-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for anygrad-0.0.4-cp39-cp39-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 d2137d83f1cca1b401447a7b4e0dcd749132fd0e9d4eba801e6085896080a257
MD5 696f9e42d59cec83307e6f2a78900a7d
BLAKE2b-256 9cea16315f1852cda93fd42e71b528bd80b0fb9c5de03d445a8c3d939200b25f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page