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)
#  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

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

Uploaded Source

Built Distributions

pytensor-2.13.1-cp311-cp311-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11 Windows x86-64

pytensor-2.13.1-cp311-cp311-musllinux_1_1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

pytensor-2.13.1-cp311-cp311-musllinux_1_1_i686.whl (1.8 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

pytensor-2.13.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pytensor-2.13.1-cp311-cp311-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pytensor-2.13.1-cp310-cp310-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10 Windows x86-64

pytensor-2.13.1-cp310-cp310-musllinux_1_1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

pytensor-2.13.1-cp310-cp310-musllinux_1_1_i686.whl (1.8 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

pytensor-2.13.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pytensor-2.13.1-cp310-cp310-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pytensor-2.13.1-cp39-cp39-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9 Windows x86-64

pytensor-2.13.1-cp39-cp39-musllinux_1_1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

pytensor-2.13.1-cp39-cp39-musllinux_1_1_i686.whl (1.8 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

pytensor-2.13.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pytensor-2.13.1-cp39-cp39-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pytensor-2.13.1-cp38-cp38-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.8 Windows x86-64

pytensor-2.13.1-cp38-cp38-musllinux_1_1_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

pytensor-2.13.1-cp38-cp38-musllinux_1_1_i686.whl (1.7 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

pytensor-2.13.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pytensor-2.13.1-cp38-cp38-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: pytensor-2.13.1.tar.gz
  • Upload date:
  • Size: 3.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for pytensor-2.13.1.tar.gz
Algorithm Hash digest
SHA256 2f704509abe811f9bca392b6848b1ed5b5011210fc19fd67d17e53f7f7362637
MD5 cf0b5b0f58b401c0dcb4017938037e8b
BLAKE2b-256 b583d466972b242964714f7fdbe09518cfc67172ad58bcfc2199ac92f296288e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 922f63beb2563b5c2039b77df81710663de380873cce26ffa4e4efb3c60a76d6
MD5 edad94db7aea49d6e5a4939d0738b1eb
BLAKE2b-256 98b03cb201b429fc38fd10dc05f9aca27dafc3790ea36c43a8e5f9d15fb6a788

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 c6ea948fd1f6135afb6d6a0d334bcd77dc60c5c48e69433b94d5c52d42909f49
MD5 c0bd6b83c96b79ef51af4d08ca5a875e
BLAKE2b-256 40c975388eef09a85ae6ade895fb03c7f37f14fa4b1a2330675549893c8f741e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 b092aa3ea0b3f94e69bfdde5941aa29a0c40edab3c87df4195a1436e60d4b949
MD5 5711ed3b72eaa3dff06237381b6f79d9
BLAKE2b-256 b66cc23948186ff4a5953a0d3ba780058ab14a61968132cd8e92fe690f8ba139

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bff9bb33bda64676fa341ba3a4426991e9fd0e024ce56037794f98ba4891f12
MD5 1888766d7617a2bdb9918a2bff259bbe
BLAKE2b-256 78ce3c26393692dfd9fdb5047352611a4860bd2adb6812fa4aead541dee53be9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d5e91a94902e8d98ae23d4ec2ce4633be49df9ed1f0ac277f748090ef4030827
MD5 1b45f06ba709c605430f8916db9cb743
BLAKE2b-256 be6e77439e3ef8eb4e3d64f34c56bfa06c32e31afeede29cbd60507f10104fe0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fe9610ed1ca5868f41dc5e05ad882cf4e2e0929f2ed199238cc88cded03604e4
MD5 2daf9450d29e3a58ba632960f330da32
BLAKE2b-256 346d36110dac2aaeecad1f13b554b43bd8225ed889028c3f82cd04e57028cc01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 2dad70049111db2f660aaac92d643df02243fe7de585ac35b2350a4706b1b270
MD5 0d94b810c7506177f1c0221f752ff1b5
BLAKE2b-256 27e525057a9333daf68f7aa6f19b61d191c5c8483b952be5046773af18d038fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 220c1b8a65dcaac49f10793d85fccf836aafdcdfcbec5980f70e3a4afd6c1aef
MD5 99233f865473545552f166e1d108711c
BLAKE2b-256 6402de642c6b1f4078d6c6f2118091ded494f7f3ee4d023feeb0aa0f2aa4eaaf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 51c4cb9ffbf3fe0b6e7580147a4b144f5a1f5ef46e69c6488f4da062f9bc4565
MD5 d6854380f8388292086273c32527f900
BLAKE2b-256 04978a6e520184f6b07313ccf8672c4ea686b098bdb35d19f1b3ed92a15bd759

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9bef612439c7cea8f046a9c4e51956e29ba67cd790a0ddc45fb98286767cf19f
MD5 5d745bbaddae6a0311f35f47d1159011
BLAKE2b-256 abcffd3e57aee0214f2ace9358c4cdb3c12e434bef0f427d417930ae9420bb9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.13.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for pytensor-2.13.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 089bfd2c2a9250f72848ba3de47a7e9e2c3387ec58fb54ee5cc2cea470651aa3
MD5 610c77bf195c2709cc90f0ac9450de6c
BLAKE2b-256 625082611188c55d4764da5227b19283bfe66bb2f7e72eb993feac3e19f4226e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 2f6e33753c9a3df143fc9d6bc38f65188b7725435ccf1a61c9ac19cd71ab95ad
MD5 a49d7764075e84997c957758991a264c
BLAKE2b-256 d9995eddb7ad624859d7a1912424abb67e22f0114f37bdc8d6679fd1b21e51a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 154d69bf226b7aec22a02fc0d817e8bbb38536a9e8843a87e0b4d732648abf8b
MD5 f570202dd4a2fe56e4ac836a8b900fce
BLAKE2b-256 fddf09490b3cf5583d17009e9616901cb02762b49cb12e4cb7c3963c4f8c46ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4ded9de7cded2ea3b2e39d8ec96b222a2594fd31705f97c689fd6a1b49cc81a5
MD5 f8128c8a1e0cc249baa0adda7d5db499
BLAKE2b-256 402351635b07d99f57e5f7f5b817cfc0159fc31f7b6b588e86dd02503beaea7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1ad9d47c54b5ed80dc6d835834287c2d64c52f8a30c7142e19efc20f19a8c6d6
MD5 12ba6850dbc05692ad1a71a4bed5d62c
BLAKE2b-256 1e87befdf5e8ac24da1f1084d299ec74e1d5086dd378ffc2b60373b7aa65c536

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.13.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for pytensor-2.13.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 23cfb9c18e709fbf56768bc357023fc71fff01561136254efe5d7d71838f5214
MD5 23d0d294907cd63dc8aa6f9c1036c585
BLAKE2b-256 ea8333a2d7a86a8f9193261828f17b5fb55362b4f7e46a425e2fb777327de8c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 5e69e517d4adba7264214494d7594cfbb9a9eab96c1e20daa21a7bc91ac4191f
MD5 7fc12cfed513d8250928f94a05c66a2d
BLAKE2b-256 615f5fb23ca46bd280ae5c58080368fc1c521c6cd9840abed8f15791ea173498

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 b950cdd9af85ffb8c5b09cdb52f5461c08f5d2f6d22fe556088e18d1f2253cb6
MD5 8e95b4ade2133aadf7651981b86491da
BLAKE2b-256 c8779bbe35530f145d7aa481b0fd50338eb0f9cd97c20d2a6928a56a3a5b2d96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 67cf6c037a007f55f63bc92272214705148715a65049749fbc231f9e369a26d4
MD5 38009df2b0f55c38e6180a61daee508a
BLAKE2b-256 35bdc14e68ab399ebd4761876f0a5e4d5977a5b8f5e54f2e6d91ccb328ea5185

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.13.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9bac5bee4bc8670a1b857d1afaa2efbfb18062ba277b59c338fb134837bbbaaf
MD5 153b5d0f89733c2a1343e94ae615a5c0
BLAKE2b-256 d7bb35cdaabd107c0b3a2709d2d276391e8ba5fc3a05ac4b60de974cbd651908

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