Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bbergerud/tenops
Creating a common interface for numpy, pytorch, tensorflow, etc.
https://github.com/bbergerud/tenops
numpy pytorch tensorflow
Last synced: 6 days ago
JSON representation
Creating a common interface for numpy, pytorch, tensorflow, etc.
- Host: GitHub
- URL: https://github.com/bbergerud/tenops
- Owner: bbergerud
- Created: 2024-06-04T02:32:26.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-09T02:28:19.000Z (5 months ago)
- Last Synced: 2024-08-11T00:50:15.914Z (3 months ago)
- Topics: numpy, pytorch, tensorflow
- Language: Python
- Homepage:
- Size: 123 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Ten(sor) Op(eration)s
The basic idea behind this repository is to allow for seamlessly switching between libraries like numpy, pytorch, and tensorflow by checking the input types and returning the proper function for use in some operation.
## Installation
Installation can be done over pip
```
pip install tenops
```Note that for the library to work you'll need to have at least one of the following libraries installed:
- numpy
- torch
- tensorflow## Usage
Functions work like regular functions, one just needs to pass in the object and the function will identify the corresponding module and use the appropriate function:
```
>>> import torch, numpy, tensorflow as tf
>>> from tenops.special import exp
>>> exp(numpy.array([0]))
array([1.])
>>> exp(torch.tensor([0]))
tensor([1.])
>>> exp(tf.constant([0.]))```
One can also just specify the module using the `default` parameter rather than typecasting directly (note that this requires that the specified library is installed):
```
>>> from tenops.special import exp
>>> exp([0], default="numpy")
array([1.])
>>> exp([0], default="torch")
tensor([1.])
>>> exp([0.], default="tensorflow")```
## Development
[Poetry](https://python-poetry.org/docs/) is used to manage the build process.