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.11.0.tar.gz (3.5 MB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.11 Windows x86-64

pytensor-2.11.0-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.11.0-cp311-cp311-musllinux_1_1_i686.whl (4.2 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

pytensor-2.11.0-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.11.0-cp311-cp311-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

pytensor-2.11.0-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.11.0-cp310-cp310-musllinux_1_1_i686.whl (4.2 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

pytensor-2.11.0-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.11.0-cp310-cp310-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

pytensor-2.11.0-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.11.0-cp39-cp39-musllinux_1_1_i686.whl (4.2 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

pytensor-2.11.0-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.11.0-cp39-cp39-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

pytensor-2.11.0-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.11.0-cp38-cp38-musllinux_1_1_i686.whl (4.1 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

pytensor-2.11.0-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.11.0-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.11.0.tar.gz.

File metadata

  • Download URL: pytensor-2.11.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.3

File hashes

Hashes for pytensor-2.11.0.tar.gz
Algorithm Hash digest
SHA256 d6592767f530f4848c875e4c96064e89e9b536f40a0faf7b5a897c9c3c6be876
MD5 d1d5556b9fd8f2c154c78a3b14a6acd9
BLAKE2b-256 461251c7aa21639efcc563b2c17d69e46161187b66e724b9bd32790f4b89dc7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 75a085e25793bf867573a453a23aa7f467deff76844c00ab5dbd7b036e124a3e
MD5 a75273e244760b59fb0b8dfcb500f237
BLAKE2b-256 75d749f6a9f9b675a4f1f9b053c550e12f623db770cad9214c3ccc2d81d901b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 aac69933a03c1cdd3a264835a8dbce25adca45637b5fa5e8d22c5dbad2326fd4
MD5 c7807c6503f1e3b9288a5eb06c666bff
BLAKE2b-256 8a33efeffa3223edefbb6f55a45c540dc2cbd809bc03cec7d1922f6662211c2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 7725f2adbcc0a84d4bb39949acff378a4c6c2b105f895fd1a781c96a33183645
MD5 ddbd821a9c3f5e876ee2821f8901adbd
BLAKE2b-256 390292423ef459689386e7f273f7153c6aa6af96a36187600c735140888b8c70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af065c8e7b54a680950d768b5dec95ce5c685c84c4f08e0f35beb4b93708b491
MD5 65e45cf2061ebae538c4baf124098437
BLAKE2b-256 69cb53db087f2171bee18f7ad604a23b5ec4669d787e8764b6b9516c6007deb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 588af0d9121a513bfe545de0c883213ba0efa1c9aa276349a54971c8354604a9
MD5 882609bd85c84dc33cda2ad965780713
BLAKE2b-256 e67c2ae2da3466e7ae1afbc87f5f26d1dd20ab8b0c236845cf59aa6055b053f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c6b8114685624adc8ec252c49b8a0213288ceef320c08fdaa2ae9d8bcc41c5ae
MD5 1f59a4fbea2bb7ed1c9f96cca5928c26
BLAKE2b-256 a85feb43ee4e269d0a93d000090ba86cf049ec34999d801a6a8b4d47de834dbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 1d26c87be4db26b04e6eccfa4e75f71ab7c6a9227ad34da2745a3327d546b5ab
MD5 5b590e89ba17ca5df6c9172d1cd55b08
BLAKE2b-256 21ff285883e5bb63b54e9befd0b71dc6e88a381755badc8ca9e6a0470dad3359

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 4a96c7d7fb58d52b80f9efb095fd103842e835ef6402e15172f4c8622c135eeb
MD5 2eea5942e63e53b91cb06dcdd8d956e0
BLAKE2b-256 6c2f5ec537ed7b30d26289bba1d9eac0cde57dfa8ecde3c00f3b432ca4660d12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f7700879ed0acef126399b31c1c47000804b54d9b9a88d8c0841ed4d7008e9a
MD5 9907edea2befde61bd618418baec0508
BLAKE2b-256 4d9c3f86adda5e90cab23e8f0ad14e8d2ef0bf73db54f1ba55c021520fa471b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1564d88533a9e1e4ac9d2019b9afe16a6e7cefbf57f0159de92de3ff32be4380
MD5 4e61f64c094328184d837a54bf421eb4
BLAKE2b-256 98805c66fd504cd776a152fb434508deec42c087875deea46d71b334d4de3f0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.11.0-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.1 CPython/3.11.3

File hashes

Hashes for pytensor-2.11.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f538cea0eadaa2f78b48c95b82db3b73a10882e537cb1ea620adba1447b1c54b
MD5 fb4a9ff8892335436d58de87c7c4a80a
BLAKE2b-256 2e3cb2e281444a1e92fcb23d49a7771ed192c7af60933c5c6b235d00acfcea63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 96dc78cf81561e8f9b92bb521c236e708cf0a47e6aca1e013d2cae55179dcb5b
MD5 4512838145f25f465baceb775c38a83e
BLAKE2b-256 6c9ac88b74d30085aa0b8b73fb33e23952e5a48c625ab95e7f33f45a5dccc2bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 524e2ff06470fa1df71158711fb2f6ddc36354de43e93fde6f04691c80422ab6
MD5 7d7e476d0eb513eb986e5facf8b03157
BLAKE2b-256 9ca1fa5749406b432e768b758b55fdbb9d4a74abc87717ff127dd70ab0cef9f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c70ee93ff6ea43c6ee009db3946abf0944d2a3ac95470f5efd552c4a85a2ed17
MD5 fcc262a73408606b71d504ab7e003aee
BLAKE2b-256 7086fc35ec0ee8b6d0e42cd788794e8269a41791c869e2fb59dc7c5c60c13fd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fd44aad9d7845c18cb6f2904d2ce3699edd5dacf2d40f9aa3dd7ea9e0b7ddd87
MD5 3b3a2f9be33689f50a9788e369f8ae87
BLAKE2b-256 ab204dc449e922d496062283920c511ff064eb19f035f4ed9835c2f2d6046c46

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.11.0-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.1 CPython/3.11.3

File hashes

Hashes for pytensor-2.11.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 8e4307f5786b40c8637d9bb3594f678ebf57087b5ad359bb0c23e11abf26bbf4
MD5 771f87769307f46691da58f84ebcfa1a
BLAKE2b-256 4f095802d48c489adfc1534982dc57ad61c0391c7d4beb41c5ed18f6503498c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 b3c43f63d1c8946c3747c8b6a1b2081a796e09dbf4c9f44d46065d56d4ae4d78
MD5 2e9eb0945a64a4fa0d8a184e61f5538a
BLAKE2b-256 9c7fbd0354bf5399118be6ad03420c75a05723f6cbda57246cd2b4849b501a9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 412e3a02b2b9bda4baa11db4d706020191b30c929f37384285e3e0f04a5674e7
MD5 cb2798aed8a78895bd88cb7a1e57f1b9
BLAKE2b-256 b457c559c7d326e536687a8725e8044691fde7864234fd507a96ad68d082680b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e0a835d4554f1fc33a6ce0ed21265ad994cca99610add81b724f95ac834ca941
MD5 5aee4e69a378179231ae28a170c71099
BLAKE2b-256 5ca61dc02c59c2f569c512661299b49ae168f62a286717f2aa20e60444135ab4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 791d430c108eebc94f7753ffa2e85b221b0e3bb439bafaee1c0827d104c73e01
MD5 c2de7c5685fd078dd72a43f32da21b54
BLAKE2b-256 4c131a11746070eb55b707f1220d4f5f8199cce4012a3bc636cc0807ef65861f

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