Skip to main content

Optimizing compiler for evaluating mathematical expressions on CPUs and GPUs.

Project description

PyTensor logo

Tests Status Coverage

PyTensor is a fork of Aesara – a Python library that allows one to define, optimize, and efficiently evaluate mathematical expressions involving multi-dimensional arrays.

Features

  • A hackable, pure-Python codebase

  • Extensible graph framework suitable for rapid development of custom operators and symbolic optimizations

  • Implements an extensible graph transpilation framework that currently provides compilation via C, JAX, and Numba

  • Based on one of the most widely-used Python tensor libraries: Theano

Getting started

import pytensor
from pytensor import tensor as pt

# Declare two symbolic floating-point scalars
a = pt.dscalar("a")
b = pt.dscalar("b")

# Create a simple example expression
c = a + b

# Convert the expression into a callable object that takes `(a, b)`
# values as input and computes the value of `c`.
f_c = pytensor.function([a, b], c)

assert f_c(1.5, 2.5) == 4.0

# Compute the gradient of the example expression with respect to `a`
dc = pytensor.grad(c, a)

f_dc = pytensor.function([a, b], dc)

assert f_dc(1.5, 2.5) == 1.0

# Compiling functions with `pytensor.function` also optimizes
# expression graphs by removing unnecessary operations and
# replacing computations with more efficient ones.

v = pt.vector("v")
M = pt.matrix("M")

d = a/a + (M + a).dot(v)

pytensor.dprint(d)
#  Add [id A]
#  ├─ ExpandDims{axis=0} [id B]
#  │  └─ True_div [id C]
#  │     ├─ a [id D]
#  │     └─ a [id D]
#  └─ dot [id E]
#     ├─ Add [id F]
#     │  ├─ M [id G]
#     │  └─ ExpandDims{axes=[0, 1]} [id H]
#     │     └─ a [id D]
#     └─ v [id I]

f_d = pytensor.function([a, v, M], d)

# `a/a` -> `1` and the dot product is replaced with a BLAS function
# (i.e. CGemv)
pytensor.dprint(f_d)
# Add [id A] 5
#  ├─ [1.] [id B]
#  └─ CGemv{inplace} [id C] 4
#     ├─ AllocEmpty{dtype='float64'} [id D] 3
#     │  └─ Shape_i{0} [id E] 2
#     │     └─ M [id F]
#     ├─ 1.0 [id G]
#     ├─ Add [id H] 1
#     │  ├─ M [id F]
#     │  └─ ExpandDims{axes=[0, 1]} [id I] 0
#     │     └─ a [id J]
#     ├─ v [id K]
#     └─ 0.0 [id L]

See the PyTensor documentation for in-depth tutorials.

Installation

The latest release of PyTensor can be installed from PyPI using pip:

pip install pytensor

Or via conda-forge:

conda install -c conda-forge pytensor

The current development branch of PyTensor can be installed from GitHub, also using pip:

pip install git+https://github.com/pymc-devs/pytensor

Contributing

We welcome bug reports and fixes and improvements to the documentation.

For more information on contributing, please see the contributing guide.

A good place to start contributing is by looking through the issues here.

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

pytensor-2.13.0.tar.gz (3.5 MB view details)

Uploaded Source

Built Distributions

pytensor-2.13.0-cp311-cp311-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11 Windows x86-64

pytensor-2.13.0-cp311-cp311-musllinux_1_1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

pytensor-2.13.0-cp311-cp311-musllinux_1_1_i686.whl (1.8 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

pytensor-2.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pytensor-2.13.0-cp311-cp311-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pytensor-2.13.0-cp310-cp310-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10 Windows x86-64

pytensor-2.13.0-cp310-cp310-musllinux_1_1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

pytensor-2.13.0-cp310-cp310-musllinux_1_1_i686.whl (1.8 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

pytensor-2.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pytensor-2.13.0-cp310-cp310-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pytensor-2.13.0-cp39-cp39-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9 Windows x86-64

pytensor-2.13.0-cp39-cp39-musllinux_1_1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

pytensor-2.13.0-cp39-cp39-musllinux_1_1_i686.whl (1.8 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

pytensor-2.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pytensor-2.13.0-cp39-cp39-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pytensor-2.13.0-cp38-cp38-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.8 Windows x86-64

pytensor-2.13.0-cp38-cp38-musllinux_1_1_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

pytensor-2.13.0-cp38-cp38-musllinux_1_1_i686.whl (1.7 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

pytensor-2.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pytensor-2.13.0-cp38-cp38-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file pytensor-2.13.0.tar.gz.

File metadata

  • Download URL: pytensor-2.13.0.tar.gz
  • Upload date:
  • Size: 3.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for pytensor-2.13.0.tar.gz
Algorithm Hash digest
SHA256 0e3353a83217bc74935ee30e38d0e0da3a942d0838717ff375295a49ce23692d
MD5 23fae32479cd6e88cb336a50c38c49c1
BLAKE2b-256 a75ec68f6e54e111a3a1b9b4bf29420ea813a645ad6c06521cb4cd1ccdc56ca5

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1c13372da07207d2d35417cebfdde9e77495579f29cb2c3f5dc8b0d676d72ccc
MD5 0f8be21fecf84ebdc87326117f092c71
BLAKE2b-256 37d1fc15b9504d06b57971eabda34dba2abfd45eef88b46f6c9e09b02cf5c294

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 b56e6f6a9e983d44f2ddf8ad9fe07499f5708c4e52a730c6dd56663146605d26
MD5 01095d6815bb2c34eb81f8568085d91f
BLAKE2b-256 dde8ae9ae05179b173aeb5ab98dd4a825a6dc018508b3683a12247a9dfa13e7b

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp311-cp311-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 978da0a7fe69c107148582d566f6572820863b218e74e13e8f88d3ead06068ac
MD5 546e9b487b75e96e33f81da39a083c60
BLAKE2b-256 8905b53282cfd14a3ac30ef77366ebc655d31a32c8090f7427a1252072e48112

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7a95647907c5ec34e23a9718e365c1d210a97a51605b70eb9a899ffd8791ec6e
MD5 18d9e637bca04b0cc2325c7388e5b2ae
BLAKE2b-256 42b0c0dcce4978dff6525a1d835e00418e426c360e062a9c1a89d88af7720484

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 44d635dbecb048038b212df5536ba7fc4302d800e5c2fe05aad0c21c3a00e12e
MD5 df6642473955cc91bffbc04cbad190d8
BLAKE2b-256 11161d50f14788cd39bdc86458d019c1bd9e1fe5784581d7d4e32791b8e4ecfd

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 91a119f5b933322556fa3b75c3fcdc2482ce7ccacb5f915ac66290a0f70b6a97
MD5 7534ac81c0d7cfd30307cb9f64a24429
BLAKE2b-256 e5b6ae13b5f5dedf0617460c69baba21cbcd063bf4be973a27861dbc3b8a273c

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 2354e21497ea888eb0dc20724c05b01bce478ac539cc157382bc682e32df1753
MD5 38ff0012f5ce92a37ea811e4e0fdfde7
BLAKE2b-256 ff2610f8e8caa8cfbca5357453304c5c977c58d178bfb277f74442a119f8a29d

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp310-cp310-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 e9ac152c506ba01acb84fb47fa03b21479c628768e650350d48a168e9ff8e89c
MD5 7398dba827a7aab8f9f4817d362dc133
BLAKE2b-256 ed7c8169591d4213db3fbdb112dbca298620b1392c4a1e0570e282e7fd50c975

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c078582ee84095450b6515e8a5dc2c8b75d9951a1caa723085c0fea9183bf414
MD5 91b8bb9bf28e78f785663b27e60ff231
BLAKE2b-256 366a6cd71a586383a5ab54803a0de7796b32a9c12f3734a39b5f2ffac0124ab3

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 026d6a5076102aa6d810f407eeea09332e8d7be4f76b0871b6a2466bafe5e34b
MD5 3d2b9db951bc352939c846515dc724e1
BLAKE2b-256 95afd066f4dfa45eeb5c9b20f27690748a5c354cce3dbf04a7bc93bf09ccef98

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pytensor-2.13.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for pytensor-2.13.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4f05550dc1864f8da014eda8b314017b64d2d62dbfaba6f2a456a3732ec9162d
MD5 5fc089d21ac88260c53b820392e01628
BLAKE2b-256 1d068ee10e7500a92c3cff604f8c45929b9e9db6754d1f035932f9512d82344c

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 49ee658f71dd295a193e9f658e2201edefb0165183239027b680e6f95b0b8a09
MD5 7e62212d9d42e7ca7fb3f4e2ef4a697e
BLAKE2b-256 b4ce65a45eb74ada855861df7d0da7ac2178edb9b62483cfe878eae3e849df46

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp39-cp39-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 24c6c79e1b415b7d1d4e1b89a7c9e1a917aad70f2b421a86c92f575d5d2e9a27
MD5 0b226dd0bc4a0bea46fa79fff8783682
BLAKE2b-256 cdc98939b745edef0e2a43a0ba9c45d1d9e0fa2fac0c4f38a812c2045c8225af

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2df461a5daf8c861edbbdefc9a4351f2f6397c5c279c0ed63377c5ab4bcc52e2
MD5 10d177dba650c70482e9477d47b6d895
BLAKE2b-256 c4338ab2b2763bc67d446c8b93c15a1106676aa750d89db589bbd707ab9ee178

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 347dccb93b69eb2f53446e061027198ac410c610bd51d17bdfa6c6b127e791f1
MD5 f6d7fa68c006dc8ee798ae17cfa49138
BLAKE2b-256 861670cff087620ab2a553f36903a6bd532978544416a3018f4a0bc914fb140e

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pytensor-2.13.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for pytensor-2.13.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e84f947a59d9fb4276e45501c4314d7823a840928515d7f2e25176fdb83ad36b
MD5 792af15b8d27406aafbc78e741dc9407
BLAKE2b-256 5b810829f2faa2b9e117fbc09e49845f893d79c9b7372890809f2a09f7e35217

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 489ff0247253e563d4d7ab3f40700ee3b44e99287efba9702937e10165d23e86
MD5 e3085852cd91f2003c69425acf866cd2
BLAKE2b-256 a9039becb77eab8a133bac3502faf5548567f701855cdc88fb73983812001b8b

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp38-cp38-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 c5958fc180986e59cb3fc224a02798e0e3ecf2abb3240658c57738a838becabf
MD5 5d40c4a3b9d8f201e7a8ca9bf36176d5
BLAKE2b-256 5debe499b7c60eb2a38180efa901e89524c83554d962febd68c82f9e920055b7

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7ed43a53f338e9570ce198d86074b59afed836e6ecd73aeabc55d899ce4fa3ee
MD5 26b5242237d827417b9ddae4856d53cb
BLAKE2b-256 432bc21c5201d38d819618b233b954371bd5e3c87f6aa54eacb2cae65037ebbd

See more details on using hashes here.

File details

Details for the file pytensor-2.13.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.13.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6ea1118668b715cd2270d3e41bcb6d615823f20f2ff6f6d3543dc5af07fe7eb7
MD5 9257cbb42e8a03f570490669bbe0a09f
BLAKE2b-256 7c0bf135f472ee0d37ef9a43b6bcc5badf8f8501e87445da7a4cfea1cad96b7d

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