Skip to main content

Python package for creating a common interface for using numpy, pytorch, etc.

Project description

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.]))
<tf.Tensor: shape=(1,), dtype=float32, numpy=array([1.], dtype=float32)>

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")
<tf.Tensor: shape=(1,), dtype=float32, numpy=array([1.], dtype=float32)>

Development

Poetry is used to manage the build process.

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

tenops-0.2.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

tenops-0.2.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file tenops-0.2.0.tar.gz.

File metadata

  • Download URL: tenops-0.2.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for tenops-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a04984a6d27b9220c926d2844d3830d3b70b644693477ee5a6450113fcefdd22
MD5 14ebd629302e6b5def6f1817ea50aa10
BLAKE2b-256 ce3908ac87db2e6e30c201a2eba8cf3c3b497e7a7bd24caba4a94ed0fff3010e

See more details on using hashes here.

File details

Details for the file tenops-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tenops-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for tenops-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe308b043c84a951178f5deecec3c80ac168b2a2420258965d5ca5686d1a80a2
MD5 7834ccb1e2d817a01857d178c70c4755
BLAKE2b-256 3e3cc610cde16216fb133fb33e165a299f414c5c7f0e44630475f683edb3b5f0

See more details on using hashes here.

Supported by

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