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.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tenops-0.1.1.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.1.1.tar.gz
Algorithm Hash digest
SHA256 e113fd1198fce5a1ffe890e89df88c5f4e6890608a3aaad4b002ecbcbf8347e1
MD5 8c439936f0fade5f04c7fcc4761d2682
BLAKE2b-256 20097628920b3b188fdfc2cd67159dd23cc8e75c66fe97e62e5026afb9607fd7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tenops-0.1.1-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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6605a3654bb6203775f8b343b3b405894941cb7016c2bc6bb32971f250d9c675
MD5 acfa621899f858208d73b138d3330f8a
BLAKE2b-256 2e193cfb9a78271d5d0ff84353db84dfc38b42f72bb3d787468cb7c72fc9dac6

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