Skip to main content

Optimizing compiler for evaluating mathematical expressions on CPUs and GPUs.

Reason this release was yanked:

accidental dupllicate of 3.0.3

Project description

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.

Project details


Release history Release notifications | RSS feed

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.1.0.tar.gz (4.9 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.1.0-py2.py3-none-any.whl (1.5 MB view details)

Uploaded Python 2Python 3

pytensor-3.1.0-cp314-cp314-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.14Windows x86-64

pytensor-3.1.0-cp314-cp314-musllinux_1_2_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

pytensor-3.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.3 MB view details)

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

pytensor-3.1.0-cp314-cp314-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pytensor-3.1.0-cp313-cp313-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.13Windows x86-64

pytensor-3.1.0-cp313-cp313-musllinux_1_2_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pytensor-3.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.3 MB view details)

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

pytensor-3.1.0-cp313-cp313-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pytensor-3.1.0-cp312-cp312-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.12Windows x86-64

pytensor-3.1.0-cp312-cp312-musllinux_1_2_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pytensor-3.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.3 MB view details)

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

pytensor-3.1.0-cp312-cp312-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pytensor-3.1.0-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11Windows x86-64

pytensor-3.1.0-cp311-cp311-musllinux_1_2_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

pytensor-3.1.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.1 MB view details)

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

pytensor-3.1.0-cp311-cp311-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pytensor-3.1.0.tar.gz
Algorithm Hash digest
SHA256 46f7e7789f4d2f6249ace6292724fe8bbc76d3131568b3654845ec3d86a4e94d
MD5 f2d79db1c0f56f83d1f1294d0642849e
BLAKE2b-256 efe948f4dfe2461049f3222fc996fd6a12549b975b0ba2ea1dbde2e9ad7692cd

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for pytensor-3.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a4afa6edf8d38a1dbb01f67c97155e2a1ea11873550838dd01f298b3b3163d19
MD5 5d78dd2798da3256362dfa33cb07f88f
BLAKE2b-256 55ca1cf71f2133f9ab1a35e812af7d4b112cd3312b090ce90188539704709896

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for pytensor-3.1.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 9c5e4dfdac9ce023def17c49c962f5eae2c092e20a8fe454b65063aaa3513658
MD5 5b4338ddbb50d6c4c5bf5be1abf6cade
BLAKE2b-256 c4c561480e2a766181b10cdcf56df633edf9c47c858b57422b7430e425e9c04f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytensor-3.1.0-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 29e35254e1e2821f5e692be1b460592085b412431209335cecb7fb855dabed40
MD5 2fcd2eb63a958a455da7e34725b53cd5
BLAKE2b-256 7244f4087ebea11753c2a6c5dcefa3c3c3ab3e86ee8b734201f9479d9917ac76

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.1.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.1.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.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5714574f7df01a7de5a187b3277d95ec60762066b26aa0c493b4d2eb0450a14a
MD5 9df52f9a4fdc1b8dc11f186cd67d179a
BLAKE2b-256 43b9fea1ba70872cebb2b76f4e606e4767c3e13ee87b8ec312e76365e1ca3bd6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytensor-3.1.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e14536032aea2354e588800f2314d43355aa562ec5de39623ea58881b3bbf88
MD5 c3b28566815144299f2f7c3a502787b6
BLAKE2b-256 331c72b4c15d2f5c163aad00a00d739385c2c09c2e7e137d2d74d9faccfc05f3

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for pytensor-3.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 42f124439f7884e74ae9da3d3d338d1d6699b6fa3014640d14f165218bfb7390
MD5 6f1d3b04d5d9f22d76d8270ca81aa088
BLAKE2b-256 c56703661cddeea51fcd496009c918e1f05af32a0c9f00437c78c5940f416ba1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytensor-3.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 86848a800ba03f6b4fabae2ad9a525d45e8518ce1386674a2df4da3da06728b8
MD5 8cc9c0777de8da5fc9820877a04a0209
BLAKE2b-256 73fd0a41e047f35a72398684360d62d6899b4c3b11dd734b57377042d9627e66

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.1.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.1.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.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cbd272e62ae190007def1c514b69de0bfef0c840628e34cee10eccbbf29ab9e6
MD5 190c6199e9a2367efd24c4434f5a29cb
BLAKE2b-256 6dd4e8fe65ec2643cb86f431c231f65470ee74a9c1bbcc968df506f0f669f86f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytensor-3.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f19d046a9368308948054e62d7fc203cb1bb40ce3c71e473808c04c7706db2e2
MD5 40d9816a6b2256e6d1259fb60e20759e
BLAKE2b-256 4f8d46e01c6d4ac66140e724e83996715f324173d6ac95857fb158251872f5dc

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for pytensor-3.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b05a05ef314bc93d25188ffb806c5968663f14de02e2519f636f168e60884996
MD5 f51147bcbc2256e584d1c9ec343a1e57
BLAKE2b-256 7101e919555726505c1b236f1fd23fb5035c5b2b0a3916a7bbb8a7c617b3c233

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytensor-3.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 078e790a39b949bd9240d71994a1be94199be38603538c7d455e893eaf4253e6
MD5 645c8ac5555c922890c01aebb7ab0874
BLAKE2b-256 311a3908fbeec936e06ea2880c00150997e9b94be310f86040426a6f60839c3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.1.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.1.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.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 19909264b0a8b0414dd2a120b117a412a26b5308fc11d6da4260f5040dd66aca
MD5 141f5bdafdc00f050e4269dbbcb6f5e5
BLAKE2b-256 bb1a09e56bef05260967cddd92d7c7e8029ad402c352e40e57b455b3b9885b28

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytensor-3.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b38f96f7db0d3a4b5f5bd3739123d3a7c6401a873ee125aee6175c5d0db13210
MD5 1defedc7dcf0387963c1928edcebff53
BLAKE2b-256 c8879d7833c03ff0037fc95a3ca74899a0506b2c0355cd8ea36b1c98b646fd94

See more details on using hashes here.

Provenance

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

File details

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

File metadata

  • Download URL: pytensor-3.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytensor-3.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 32b509bb072d982e4f9076ed28617605e7489ef404f349c50d90eda09b54d18a
MD5 d3bc097f98b0fb62519ece2be2fe94a5
BLAKE2b-256 25fd6b4a5c2d075ff4d223a911da3af1a3b920ff73fee189277e65e1f930f6e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.1.0-cp311-cp311-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.1.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 607819e6ec868d08ef96fb2be723f3eeac4f24f4da2da86b2837f85dc1601e0b
MD5 481dc25b3200f1261994bdfb4c713288
BLAKE2b-256 6beaab7c26a52186d239b535f0d6429ab4eebceffcc9580bea647be6969edecc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.1.0-cp311-cp311-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.1.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-3.1.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 61e3fbcbdf2090e84176487ada533075c88334e57032997978fc037a8fc826ea
MD5 edde1dd39a6af71bcceaf9f5e34b278d
BLAKE2b-256 f497be9434a9dbf40764b78d9d9cda91581ae7a796b3d39798cc4e0f1f64f8e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytensor-3.1.0-cp311-cp311-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.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytensor-3.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7cfef4628ac6352cdd3536a6a0fbdc0cd25da6d034d5faf4864329a8fd49f7cd
MD5 cee662487449e7b4fce6d01bc1504481
BLAKE2b-256 d75ec37573265f2c74a542ced38474454583f060f0e1d40fea941f9d37e2fb5e

See more details on using hashes here.

Provenance

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

Supported by

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