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)
# Elemwise{add,no_inplace} [id A] ''
#  |InplaceDimShuffle{x} [id B] ''
#  | |Elemwise{true_div,no_inplace} [id C] ''
#  |   |a [id D]
#  |   |a [id D]
#  |dot [id E] ''
#    |Elemwise{add,no_inplace} [id F] ''
#    | |M [id G]
#    | |InplaceDimShuffle{x,x} [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)
# Elemwise{Add}[(0, 1)] [id A] ''   5
#  |TensorConstant{(1,) of 1.0} [id B]
#  |CGemv{inplace} [id C] ''   4
#    |AllocEmpty{dtype='float64'} [id D] ''   3
#    | |Shape_i{0} [id E] ''   2
#    |   |M [id F]
#    |TensorConstant{1.0} [id G]
#    |Elemwise{add,no_inplace} [id H] ''   1
#    | |M [id F]
#    | |InplaceDimShuffle{x,x} [id I] ''   0
#    |   |a [id J]
#    |v [id K]
#    |TensorConstant{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.10.1.tar.gz (3.5 MB view details)

Uploaded Source

Built Distributions

pytensor-2.10.1-cp311-cp311-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.11 Windows x86-64

pytensor-2.10.1-cp311-cp311-musllinux_1_1_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

pytensor-2.10.1-cp311-cp311-musllinux_1_1_i686.whl (4.2 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

pytensor-2.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pytensor-2.10.1-cp311-cp311-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pytensor-2.10.1-cp310-cp310-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.10 Windows x86-64

pytensor-2.10.1-cp310-cp310-musllinux_1_1_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

pytensor-2.10.1-cp310-cp310-musllinux_1_1_i686.whl (4.2 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

pytensor-2.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pytensor-2.10.1-cp310-cp310-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pytensor-2.10.1-cp39-cp39-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.9 Windows x86-64

pytensor-2.10.1-cp39-cp39-musllinux_1_1_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

pytensor-2.10.1-cp39-cp39-musllinux_1_1_i686.whl (4.2 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

pytensor-2.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pytensor-2.10.1-cp39-cp39-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pytensor-2.10.1-cp38-cp38-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.8 Windows x86-64

pytensor-2.10.1-cp38-cp38-musllinux_1_1_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

pytensor-2.10.1-cp38-cp38-musllinux_1_1_i686.whl (4.1 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

pytensor-2.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pytensor-2.10.1-cp38-cp38-macosx_10_9_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pytensor-2.10.1.tar.gz
Algorithm Hash digest
SHA256 6fc96a75cf5348e89f4f44927c585f6f0059c4ab61282564864f67437557bd7c
MD5 a83187c93c6218d4dc4bc810e11ac9f3
BLAKE2b-256 79ac9b08603342ecce5228438286ee707efa7ea06e2a008e97f0f9cbb1cfbb71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ec4dfe08b707f9ac8ab8ad083b385ae4632d895ad8220e112d9824e3c1adb979
MD5 9f0a681bf4f6cee196aeb12f4fe19777
BLAKE2b-256 1ba74af949047a6a0ff88a13610ac46558ce9674c26c4ad271399c9f216923f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 da2f3d7f1fd84ca13fe2f49cb4588e6cee38bd64b544a1901052bc8f016b88dd
MD5 99c44c9fc6dd011a6367c753fcc9a5e7
BLAKE2b-256 b53f4987aae1501b7e279aa354221298f622244a94721cb5469aa64fab3b52bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 ad5a66fa25c183c68b37627fb38d96f98cf563a03095539bfc03543476debff8
MD5 4a13197e72f5977593cc23d49af7f578
BLAKE2b-256 4f8f8f118f9dc7ef1a7926da9e66bce9a1063ea6210c75a97c1331fc5193071e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 987689e3ffefe23871a850ca81cbf72ca8e4968d88c8059fd8e8a39e08e8c908
MD5 485a8ba878cbb9051b0aced8cd7c0212
BLAKE2b-256 16af1aa98e9a31d6eb634e9bfdecdd289791a412edb9c6261cac95d1536287ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2106d42b27f270f9589cb5b1cd28925762fb78a81e566733e53390002c931215
MD5 6304e7520272509db6fb4d940dc7856b
BLAKE2b-256 706ccbb53c598ce8b87bc23267d8b4710d79a836753a2f5af02e7da62f7e7884

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ad00ea90b82898046c49a671a8e7032dd722e448fd81af16be29fa1f287724de
MD5 8b6d343b092f39864390f2ee0cf387ce
BLAKE2b-256 711d39a52b94193b5849ed67d0f162e47c8e39894687573bd4e9f5e9cc7afd4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 3a6a8ce00355ac7eb6fc36b4dab89e777de42072fbbb8f9067f1b6643bbd5e2e
MD5 51423c58ad262f43ca0c4e601968f0ae
BLAKE2b-256 c47ba71445206cef16bb9a4f1d74285ab5b2b84cfc7ba0c26850f4b6a115fbd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 42e692e3d2bbac26686a50b9b8ba079106c1d0b54e0557fda3f0add88e85887a
MD5 698b2fc3cb325496e1cb8f2980cd2b7e
BLAKE2b-256 8ba4d3e35700ef8f7fc530af8b2ff2a4021dc56b3065fbc54353675f36e5f37b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 680b5c3b80e8f82ec63c6b80e55a0f201dcf7a2bb25a3bcca428aa8765ca20c8
MD5 e8a9f4032a21446441d560f2fba962a2
BLAKE2b-256 8ba9efc2e6f7d62375b129096a2091207ab08a36ea67974fd24a19f65a6c0063

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a0281be1641cc0899f724dd574da8b3c062c04a4324a29fa692c3641c8902085
MD5 f9e94c7739442384b33bb3637bf7ac80
BLAKE2b-256 13b06bea2a977670d55b48c7966f22787bdbbfc4d89a5cded4a1b900b0870e3b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.10.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pytensor-2.10.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 946b3c0b67ea722d3f658eb92d09ee5b4f66cd790b4e3f834cbaf611046e86b7
MD5 f2f3841af97cd8e81f7e937b5474b4d1
BLAKE2b-256 2309c770305c9b1b618660f952c9e848303edfda00dcbb3ba28a167ae86bbbe1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 846001ebcfb3db61a15e2c56ddedc48f8b284afa03e82aedda1f4253869f8672
MD5 203fcfe62544e8fd7da99796c01336af
BLAKE2b-256 b0a8698874badfc8041dccfab571730c04a047a3ed8cc3135a812b3f0f8d3e9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 e4cdd6aa052fe3846c2dd5622bae377fc4297574d54383eccebf1b904f3f47d2
MD5 237fd36cb64bfd17e9c8903981140c91
BLAKE2b-256 6ff2beec4afc90554e083152aebaa2e7892a5baab40ca427e6773bde1cc29065

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c3669509b7d1b034ad267ff9f5a645bb2f1df35563631b9754d4b4776cc8d20d
MD5 175c223a6934bd1ee1d5857f9aff61b7
BLAKE2b-256 e9ed4c51ecd145ba3143d44a924131d8f081828a9fa2fcee5ad1d113f0b37987

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 85ab5fa0b575c7ac26dc51d9e9ab279ffbfd8eb8f16a6081ead50bd02d7843fe
MD5 9baa0892e27c11a4f8a29fa720652a5c
BLAKE2b-256 896d7e9075f366b81c8408c76554436bb6576318771335fd64992146e98fa2c8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.10.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pytensor-2.10.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d76714740781063d68f046cca1e3b3aebbc2a429fd293731618d6f28433a2de1
MD5 a8fe018b0959bce7d26d393f44b40221
BLAKE2b-256 545f4105d4f2436fde68068f62eb7c9aa52f7bff7201a3893ae946dc3ee62ae7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ff9fca7614612595f6bc8b8d67d2b6e11c3f84cfb87d77a0b706d5a07d1d2e42
MD5 5b8a2980ee420bcfb25fc2eec38cdb47
BLAKE2b-256 327704248def5c38241ee01aee672859712098b7d55f6a81499d8bbc0c30058d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 5bfc4bd76d49e549716b84de79d007f215d530050bac5933b0a5dba2f6d84710
MD5 fe9b64ff5a9443339873ee2cc2e583c9
BLAKE2b-256 39ab1d82d9fdd024688c09b820eddcd8298b9a47a47183067c88f511a391cf2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 baa7ac7e0cc90fc8995c13eb5b3845d5c3513da908925e1a0c5dead30430fcfa
MD5 3885186b8b2cd8a60744ceb7c792ed98
BLAKE2b-256 0e045092cd2c0c992d8a4cedcbe611853ab813aac792990eac60b0f1fb56167b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e01d7d32d4fc65930855424deb7d9311a3ea9db09a3b0be33b5d5e4c52b27a5a
MD5 3edbc7d8caf8b891be8451ac6bcd2919
BLAKE2b-256 1ee9057169449a799614884a44b44fd167dcaf6fdb85e90ea92e718cf1e3fbec

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