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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

pytensor-2.11.2-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.2-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.2-cp310-cp310-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

pytensor-2.11.2-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.2-cp310-cp310-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pytensor-2.11.2-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.2-cp39-cp39-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

pytensor-2.11.2-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.2-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.2-cp38-cp38-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

pytensor-2.11.2-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.2-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.2.tar.gz.

File metadata

  • Download URL: pytensor-2.11.2.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.2.tar.gz
Algorithm Hash digest
SHA256 24c2b481a84f580b7f0f67c4dc414e7b6cdd8b8daef6fae21cb43119de7158ec
MD5 8768f4814c9fe57803c94691c5ff7d7a
BLAKE2b-256 58c96dc7a6f096a919dca3c803eec3d1488ce0c286882302b193db3e0d2337eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 618c6b4ab111fa27b731869b0cc0b7949309a84bc7107242e8837d5441c48fdc
MD5 add77cbb5ff3f7e2fe602fdf4d9ea123
BLAKE2b-256 88eb80d0c7e34200a8685b456d9841692e4e382cb7ffc3e0f507faf75d5bd752

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f62b04b3ca556747b098fb9640f30d31cdaa58681fc62c8602d331b0a84927ad
MD5 c8ea04933dc87c443fce4ced2335481f
BLAKE2b-256 fca8a9ace0d67af504c47a378da94dc695c34b8976ba16090f60960a0dbd2019

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 463dc7ff89a7833bf9b3d709388a262e2f915475565b620f85528f9ba93073ca
MD5 87e3def3d2513f9db99595fe27c76db3
BLAKE2b-256 81f113f0071044aab9c986d47f81c2ed3a1329ad91be04299f03323cd0231ec7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 42ac607f8aef21b66b04371ba6f8346ff7dc993de5c091b65b112d63d529569e
MD5 7141668549238e53da00c581d3751d68
BLAKE2b-256 2ff7364741aa3bb7f8e5341a0c4f053925088b4228c2e63e7309b4bcb6313d76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 99ed3e8934f32431cd75f8515ff791a4ffe8d0c4c4821270f660abbf55f90384
MD5 38f0a9d3c4b8f486a3df30a31965c4d1
BLAKE2b-256 fa7dc6d18dc429623dcdce55db7a641727285ce6e073f9ae7dfe83268968f7ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5fb7bc4b012a46a999c4fe3fad646a79990056d2ae51701c7b27b15879271d4f
MD5 e82b156c40161fab933a84b1345304e2
BLAKE2b-256 d76843ee708e713f2e15978dd93ce090e3bd81cde8cd6641f4eddb6bf3dc38b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ab528d809ef29c60ee814c9d182bef15501978f2e378b091dfd89ea8777b1397
MD5 d73e3562a494f86528e87012debe4d47
BLAKE2b-256 e6c7bf8e0738230311fa9d118f698f5fe17c0f5c9fed7d6ccdf01b7029bb3545

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 9a0297b5a6678c6527285ede7275760584f9b5c17b6465e9ed8926dc36c32253
MD5 7f8fa39644a95b7ce1cf92d1e36099df
BLAKE2b-256 66ff78c9ac91c2f474973fefb1636f3d39c9f40d47f9885b26da517a98989e61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2c912191f6e74d505670936a50f5a51bd9d38c127b8db8bc752498385921d019
MD5 886eeb273c59c6b1554a9e33d340f1ab
BLAKE2b-256 59c8aef7d52958123fcffcca5232ae4f0cca25c260f08232359f0a57612f3f02

See more details on using hashes here.

File details

Details for the file pytensor-2.11.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytensor-2.11.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b1b39492c2630fa3e9ae32e2e630b9b9cf6ba6c529496edc204048f96e52218
MD5 894fb027370c9c870afddd615044fded
BLAKE2b-256 41b43019f2684a2b2739caed7d50115431bb97282baad0ee5e7b44cf5a61b9ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8330efbbb9926c57bfdc8d06fc4517c38fe6120c8d5f1dc5467af74547e355a7
MD5 680d803ccd24da8d037ae73917782abe
BLAKE2b-256 cf958d5f15405fe0d9ebf6d6c618054e89997cadfefa4296db32532bd228c031

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.11.2-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.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 331540abd323d9832b6258cc0e76dec9ec2af663f4a6fba7d2e334608ac72ac5
MD5 799aa319a9259365416f1f688b23216f
BLAKE2b-256 d45a862719d7d16e0f14ae1d3e4ed0c19edf584de1270996aa8fe0cdf203eefd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 3f799fdc48a1182b27505dbd7036c34d7cb2d83a1199944171b40a7b38e96cbc
MD5 ccc648c40ada0eee2b1f7bee7676bd2a
BLAKE2b-256 aff0b406587140676b9e978b4554b1fa28490ee671a2c07a6830f0a432021ab7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 6be7a89897bbb36e769bc86dc68ecb6c00ac75a1271ecb5cc70dfb5472760f81
MD5 2ed56ed467bc2b0cafcbaff0b6bff62e
BLAKE2b-256 2185f6b8b4b7171ca7f36fdb96672263c1cd1a5dfd33ae1d53064c11e872d8f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5fbdf5d9924f674aadb9147d6b2964ed3227e7d93bf2c4cf5f745fb958e049e0
MD5 62e456d6c5aaf78394915a2e81faa213
BLAKE2b-256 af111ac09f89d026f2fd4db371db632bdb62a257aaabeaaa00c7998295e06c0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a6be6f75ca847a4e87d246a190c9638552a82a2b48b70cf1b38504d39de41467
MD5 fd95107f3d2e4c7b55a17717cd11e098
BLAKE2b-256 e231ce208719f4fedcf163588fb13b757f4bdeb73da6792e434072ae1f77cf5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.11.2-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.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a71a29a6105430e819a0593a69132d9cacaf047a7f89409753146aa77645d954
MD5 57e1dc48463e3a085a1b444b829c797f
BLAKE2b-256 5125c894c12b102d605629493a914fadacd2a5423e0924c2c8daaba6d4f2a396

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f2cddd189b9313b89d4f0282e2551ccccc4e9e6862b343174c1f3c250067253d
MD5 37460c5ae779d9c1c83dcddcd9835b0d
BLAKE2b-256 784e08f672ad2ac9666c95207f47f5799db030a112d32a160808db3a11493dc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 de9928601211cb146e28f4f40040824c098d94898ea1044830a5c1a6b2638365
MD5 a1c8c58de1f421f9fbe5635f0434afe9
BLAKE2b-256 9a640751cfd34e63bbac2c6be40083d8b8c58b7ce4c6d92167606060ca50af79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 77449e8097daf6f187de48da801b795022adfa7dcb731af90467ac59ecae52c8
MD5 eaa26d39cc439a15785dbcedfcd2d0df
BLAKE2b-256 a38d7f56484ab0b8c3a522be703c8b246114e0b4f40207e53e5e76a8030cb54e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1b078c22f94dc66cfef9f5da2a39df6d8b68a801f59cb82c2e64e490a267d347
MD5 b1cfb0d64d371f83797fdb991080ea41
BLAKE2b-256 cf826ebaf7193bb5025672e148613a1459d96cb43bf80d94bdc36e8d0ad4b0ee

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