Skip to main content
PyTensor logo

Tests Status Coverage

PyTensor is a Python library that allows one to define, optimize, and efficiently evaluate mathematical expressions involving multi-dimensional arrays. It provides the computational backend for PyMC.

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

  • Contrary to PyTorch and TensorFlow, PyTensor maintains a static graph which can be modified in-place to allow for advanced optimizations

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

Background

PyTensor is a fork of Aesara, which is a fork of Theano.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytensor-3.3.0.tar.gz (5.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pytensor-3.3.0-py2.py3-none-any.whl (1.6 MB view details)

Uploaded Python 2Python 3

pytensor-3.3.0-cp314-cp314t-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.14tWindows x86-64

pytensor-3.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

pytensor-3.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pytensor-3.3.0-cp314-cp314t-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

pytensor-3.3.0-cp314-cp314-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.14Windows x86-64

pytensor-3.3.0-cp314-cp314-musllinux_1_2_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

pytensor-3.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pytensor-3.3.0-cp314-cp314-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pytensor-3.3.0-cp313-cp313-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.13Windows x86-64

pytensor-3.3.0-cp313-cp313-musllinux_1_2_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pytensor-3.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pytensor-3.3.0-cp313-cp313-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pytensor-3.3.0-cp312-cp312-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12Windows x86-64

pytensor-3.3.0-cp312-cp312-musllinux_1_2_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pytensor-3.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pytensor-3.3.0-cp312-cp312-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pytensor-3.3.0.tar.gz
  • Upload date:
  • Size: 5.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pytensor-3.3.0.tar.gz
Algorithm Hash digest
SHA256 237236085e4c005a5a8b129c3aadc598c358f6dd2f929c490ab9696a752a320c
MD5 64d2b6839cdbf0b6c38573730cf604bd
BLAKE2b-256 235893480a1d25b17a89ec3759e1e6934c1ddb97f02d291117f8a34fc881bb7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0.tar.gz:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytensor-3.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pytensor-3.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 57ba0f462682fe4edcf2d87c842027067e04f05aef86b539a33e1369a62fb74e
MD5 29c67860cf715348fe71e53759f71b72
BLAKE2b-256 56c1d36e2db06b2d12b9e0c8e73c3a6bc32683e732db74180b0231859a69f2f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-py2.py3-none-any.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: pytensor-3.3.0-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pytensor-3.3.0-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 a5b61c119b96a629b005f09fdeeea2845859caf4a3add1e7bd5dd237bf76418d
MD5 c631eaacaf2f670e9084237dea42408a
BLAKE2b-256 43bc047653cfc2686842d3610a5362195bc95e519a22ea4d50a19180d0afcce3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp314-cp314t-win_amd64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1d1ec4547144f4081b26bba317ae47ef2e76ea71d35d7226069fcc6f70eceb10
MD5 1b47199b0882e98937dd34b558ea463d
BLAKE2b-256 3475c7850ddf2e631a29d9340f5735dbaa3c8bc4e6b39e0b10000d8f635c9840

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d3747c185d0ed5c2f643e159c1bdfe89470f5e051375169b062421f0a8b64b67
MD5 4c46b2e4094e428cbf15b6d04bd6dae1
BLAKE2b-256 86e811ba8903228e26309947ae342e798316b8114cc5a8d69e58415bc000cd14

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 782cbad78ef5434f8611976ba5fb41b916fec79f3ee8d409128f1103816b04f0
MD5 2dd4cfe6e5d3d52eefc37831b7f65f38
BLAKE2b-256 7b484d28b51d2d3358f8160df2b8556d37056647baa1af65d6e60dab4ee50563

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp314-cp314t-macosx_11_0_arm64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pytensor-3.3.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pytensor-3.3.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 115ce884c378a476397071c07c3de228b6defbf064de0ccca8a8ebf369093b74
MD5 7811432484c591a80164afe75d097f36
BLAKE2b-256 154d0eae213c5197c6a0cb4080f984c7295cb53af6d0ecba9ece190a6ae9560f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp314-cp314-win_amd64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9c67e938139be550b531f7c04a33a277084e3880776dbe17254df80d69587b63
MD5 7cb61aaa5ae861bf19a1cd62fc404383
BLAKE2b-256 89040fa74eee71c2f86bafb60f436e56810694af660544babdbe51138788f23f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp314-cp314-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76879ea107d2e0a2c775cf2b5f7edb63e8118017b04d62468a6cb2219b0805ca
MD5 56873599842b6b99f9bd216bb91d6013
BLAKE2b-256 4dda007be278565871eadd1ce7abda66532cecda68b63363be44f321f3600c43

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5728796ba3bbefb196311495315ebcd7db39f19564674ab958d5e92e02df5ead
MD5 f34f0e7deef106c91de8a3606f1a5720
BLAKE2b-256 9e743b17e08f1d9facfa7772ed32e1614f2e676f44093b2b717dae89a0c44161

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pytensor-3.3.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pytensor-3.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 746b4a34d57eaec18fabda9057bf0090f7e30b4ab98d6a39aea04be805e14091
MD5 5d8d2a71fb9ee5665664c0fa4bcf24b3
BLAKE2b-256 9ad3916807b3dd39f2803dde51f412a7f39828bb26a1fa389d0c1f4e761fddf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp313-cp313-win_amd64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f703b18a6ff113e1abfeac18d7d01671db5510116b89b3332a2a3f98fcbb77bb
MD5 2c6af396d3f76c1d6a150a0e1604bb99
BLAKE2b-256 7dcdf5331275960093c8d5c4286fa5ec88e86e657ba889672e9e9b81474d46c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 90e34214e04ffad6ed720838ddb5f8e31de9a06a347e6ddb2fbc108eb8d1b126
MD5 e240ac48456ce467f0765a38f01d9357
BLAKE2b-256 b9cc22dc4178cf053df345cc34fae455c34ac061b1829c619091f388c2e904a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aeda357cb1752c5e3701ad8016721a40a952d5d85753c0eb6005311ecb7a53c4
MD5 0248eaf8b8bce31a6e5d2cd6c0124f0f
BLAKE2b-256 84d7287c374fe25382532ae0fe9a81af748dcdc9355d670eddf2920ed5066c9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pytensor-3.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pytensor-3.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1d873a5d0d9b9a287bc8255141d8f9d4124a5560f701efe00120e5472e9683a2
MD5 9750f0c005e477f6de0a1c739324ba21
BLAKE2b-256 1f7d89aa8e1915693bc1216d11d19decddd9d0142c476b780056632116bab9e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp312-cp312-win_amd64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 03c082d17ad341e561ae5c3fa0b3e3c402d36bbf725554bc47c11df0bc92cc12
MD5 248176c7234311a8f632f924d95f269f
BLAKE2b-256 b5e91e54e4761a17a78061bc29c0edf4692b234c61e44571d5c7e2de5770db38

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ba7b316d747e55e518aa10f6daf97c906669712c04fda088696044ec89fdfcb4
MD5 0e3e2ef0c18856af293b42aea8eed225
BLAKE2b-256 e0a1f34f52e167a82a42caa2ebb9f39f8ce31a0160b26f83fb5c434b7c92ad2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytensor-3.3.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytensor-3.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e65d2683c83a56b52ed4d3e02a0137b9bdcba66d96ae1e05487847fd104b5f3c
MD5 6a9aa2a170d0748227faf32dc705cb0a
BLAKE2b-256 08c7b5c6b8f146ebf02b841ffc0b4c2287d7aa61309eca11685e1b571af34c1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.3.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: pypi.yml on pymc-devs/pytensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page