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.

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

Uploaded Source

Built Distribution

tenops-0.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tenops-0.0.1.tar.gz
Algorithm Hash digest
SHA256 27c4db97e230b2eb4302c4c8d50908ef6b496e08aebed9bc96dbb521d93fbe4d
MD5 39bd536e31ac7a8da4692a94a787d5a8
BLAKE2b-256 b8f0edda898b992920a30a9c3614d52940ac48d6e61e39c24addc70b7f888731

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tenops-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25ab51723947c56c510ec1a85e04816ef89c867a3df4a5b4b7ddc29cd7e3ea56
MD5 bbedfe3c2ec4a212d2f53499b53c90e6
BLAKE2b-256 54a6e5fe7c2db7b3d9467bd7dfa5d2cfb95429d1a189282c3dbc7f2974de634c

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