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.2.4.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.2.4-py2.py3-none-any.whl (1.6 MB view details)

Uploaded Python 2Python 3

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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

pytensor-3.2.4-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.2.4-cp314-cp314-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pytensor-3.2.4-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.2.4-cp313-cp313-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pytensor-3.2.4-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.2.4-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.2.4.tar.gz.

File metadata

  • Download URL: pytensor-3.2.4.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.2.4.tar.gz
Algorithm Hash digest
SHA256 91b5d38c9d0162165544b29cbf2ae029427cab0a1c773ac42f687e41a86f6c67
MD5 62b01421651f21cc70c58085f9f5a681
BLAKE2b-256 294e37b213744ce0b6728ecaada34642b05cc7ca686c0d14ece94155a2c0dace

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4.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.2.4-py2.py3-none-any.whl.

File metadata

  • Download URL: pytensor-3.2.4-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.2.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1befbb3755fdf78df1c9cb61fb0bf6f473e781ded6b80e2fd32b06b5983659fb
MD5 5074e2d946662c3840b9c0797885927d
BLAKE2b-256 a84d6107e18af80f4008b76e09ed6032ebe4c67a8484d60fb19b103ba73d5468

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pytensor-3.2.4-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.2.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 194d14518cb052295d7262ca5093335fdaa54506856564e1622a9f6519286070
MD5 9265fdda561e389c48ed2840f920e2d6
BLAKE2b-256 59358cb7102bb9b48af28d1bc4358ec3ad0854dd89a9effb9d31832c426e0d97

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.2.4-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8a665777d554e2c9e1c38a44c733f37c6e59700664abd22d75691a6d61134f9d
MD5 eca8800093f16e3ec3e312c16d49e708
BLAKE2b-256 02668e0ded716562af386461562cfc91253c340db2e0fb2a7b41cbda749c1de7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 793d4975b08526da2da1c177a6aabd07c08e321bde5a11ac5f9fb9f51f3fa0db
MD5 38c9a13a7452b4d062e3eca918fc6a37
BLAKE2b-256 37ba4ac2da153186a158b0f96ec859f218846286a268cc8595307f7ac21fe635

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytensor-3.2.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f358780d05e374996b5c705370df9cc4f44089816a9e7e42c53e7c2ac595afce
MD5 820faff97ce304516a450cc6e1baab90
BLAKE2b-256 53f8ccc0c075b0e9f13fa3a3257eccf7a87a6a6ad59deb8e1cd8eb4dc43d7c41

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pytensor-3.2.4-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.2.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7bd6c0d25fe4e8dc92ef91eb67cf2e814c06bbc3ebd16632b7fb732e93ede025
MD5 83ed27510f593c64a2552001873e70ba
BLAKE2b-256 2d188211f489a0ee32df6d0bfec022b08f7b9550e52eebfb0372cac8b99c1318

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.2.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b1219d3207efc85f5dcd30f76e2d7b91422f4df70a634334e4866b3c5a3e255f
MD5 1c1d127869bd868f8f88f653f5b3f055
BLAKE2b-256 4571da42e44c40d6814f7c9cd2fc2811536d371be5e847f1bf7cd7a777fc47ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.2.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e755ffe0a9e5debbca0f13df629db322b240bd3981361ebd0f13898a8c7e2f4c
MD5 5d9a47af6fb3f7b3c3a48962b26e12f0
BLAKE2b-256 3822793cac42dae6939a5c0d49986195ec6cec760a884e13c84b75bc163a09fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytensor-3.2.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eeecea8c7bbeb6f767b3f6db9477779f0a7d2607b251c9cb8f74941913f2ece5
MD5 b6e1fd83561cb509d79f91c6dd32b35e
BLAKE2b-256 7b730d839c161201cd6b751c306391022386d863d11b2fff6f23483bd2537ec4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pytensor-3.2.4-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.2.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2bb80bfb27e6ab9c8ec1ac486b7bd97519836cf2a9a886e08d75a14bb4214a8b
MD5 007a5f61d0857b864120aeeb1d408034
BLAKE2b-256 aaa006ce3a98c44c48fc27e32b657e8fea13750ac807fb35aecfa95dc97b2200

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.2.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7ac1375bb7787699b76a94f1c7a06637fa020b037ec2ef387c80cb6335e66a76
MD5 22ee45fcf198f717a1a8c02e188132fd
BLAKE2b-256 943f3981ae3c1814200db9cd58392eaec17a3d2f237dfbcad032451aef9b4c40

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.2.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ef506643a041682b58326a506abe3ebe88221e350de95c1b5ca14f36cd24e951
MD5 05e6749cf00bb95b71c389d27a92bcfa
BLAKE2b-256 e4648c1d0b9bae24c1e0e05e4c85adde8c86bc469c7f090b45a3f45d8237c46a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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.2.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytensor-3.2.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6acedc6572b001ed35cb9b611d68518f0a95ca8087608262bca25870ae664620
MD5 d0a397d407cb1f514a1751dc6c44ee3e
BLAKE2b-256 c9c4a9dd5d90e2fb283dd195cf092850a310d0aebe4f57a99d50a6f8d818f041

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.2.4-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

This release

3.2.4

Supported by

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