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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

pytensor-2.10.0-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.10.0-cp311-cp311-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pytensor-2.10.0-cp310-cp310-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

pytensor-2.10.0-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.10.0-cp310-cp310-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pytensor-2.10.0-cp39-cp39-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

pytensor-2.10.0-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.10.0-cp39-cp39-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pytensor-2.10.0-cp38-cp38-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

pytensor-2.10.0-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.10.0-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.10.0.tar.gz.

File metadata

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

File hashes

Hashes for pytensor-2.10.0.tar.gz
Algorithm Hash digest
SHA256 fe74d2138d1f310655f33332d4f36da10b63c306827d8ebd99786a5acde40792
MD5 865b10d09ac0b90bec9737fc33b63ea9
BLAKE2b-256 ee20fb99ee97fdc6c93e021e1cea52636a95884b37a9393f67e25388ec3a64ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d4761760a4a58bbbd72b14b7d764db1d88012a2b7911962d471f3903b111e569
MD5 3df29ec47dc46beefb4c4db4808df9dd
BLAKE2b-256 9e999562839d664aa4b91f5f3ea98d98c14854e72f8cf0351496063d0d40ea6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 8407a57e318ae0b2f3e27abb678e42429a835d464fbdbc42aeaa5fe7fb2259b4
MD5 3fc581d8f198b8018a030f936881286e
BLAKE2b-256 1d8feb2d3fbc1e0edba9a480bb90b73e33ac5e239bad892bce33d88d856f5523

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 b796feb3005dde5250faf8c6d49240d4f881ea6b4dbfbc4ed63a0fab32536e6e
MD5 1d05ca8376d70220f6f61a3111f283c7
BLAKE2b-256 8d580a97188976f51e2c7ad3f97ddf985049558d709b18d11a1a11b102491896

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e3df197fd1eb4d526b4819c27cd52712b0838a0e9fe38f26a083fe1a42884662
MD5 3abfd08311e0c4f2166e3afa05f295bf
BLAKE2b-256 cd16c4f0b92cee149fb3958a5fe4c1c7c5bbed72779d5e53fd4dc62355c9d99d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a384026378d2c497c4a0c77ffaec230718bae01e6545b49c1da88f0d23f5df3d
MD5 c7ab7584b8560cd7eb3e1165c47edb5d
BLAKE2b-256 2f8e9c06ed22d550893993e3f5a2e33319b0e036ef8136ece6ceb2947989391f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e1e23518d74e493fe2ebc3e634bdb97fe774a56449214488055805ce0bd79849
MD5 740aaa7efa2283c1d0a0fee69939390a
BLAKE2b-256 299e57c2be4d34592ee688249dda4b1123f4faa0b9583989e34636cec522052f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 0fcfbcea5a1a6fbf7c8abebd6fa15d8a016f71c4bd9a2643cd226ebfe9c3e647
MD5 5e01318d93148be401ef17b0d60edbd7
BLAKE2b-256 ab8b276562aca9944927c9955b482a02bb70c11f6acc8801fc5fb0998ca74c9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 5eb940262a74ddf07b097571d96a6be7996c6385ef19459339281cf11ad04b8b
MD5 7a296405bbdf526eebfb1a4e86c437cc
BLAKE2b-256 acdf25ae0f954014834f87a989ffb144000be75c833f885c9c40978320d7ad7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce1e14ab7edf3b092725beff9176c3ce8055e679274c18b8060eaeaec90103d7
MD5 9817d565f8f4353e7e6c61c9f7921fb4
BLAKE2b-256 1117b04c073a50f6ab47f12b6a5ea6b192ea949b71445a9c65b0ef3f0ddcf1c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c1bff8106668a8e00803090865d3f4d9e23c7410255b72cc439a2d89b05372c0
MD5 ac1ffdf1011aeb2ec3ba7752f7e25195
BLAKE2b-256 0b666ddfcb9807122259437c182c8d6d67376ca10739dbb6fdedc36598d0e3c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.10.0-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.2 CPython/3.9.16

File hashes

Hashes for pytensor-2.10.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1fd29fe3908aedcc3c1ac33437dab85a3ed2dad4146af4c73227434b5431c51a
MD5 8019b15b9fff23270f163455aa0e9dd9
BLAKE2b-256 5573d505dc1f815b67e87db6c7c02304dc8f04f4059cd438df6b0029cacb6f3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 e908892a6d329b0d24a57aee4cc5fcd37f8d2b4cfca225e580c0a8820326174e
MD5 974eca71d36ed0133d556e38d5df5c2b
BLAKE2b-256 aaf7b1cc04c151df96833b96c8a495a4f0929b1da74c67d60fcf6a3803e462fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 700d66410984a51b5210c153a4e726f99884850944ae7bc0c9c24c17e0384462
MD5 a6e77cc2a915a4a7b36a1e2f0ae29ba8
BLAKE2b-256 c9b064c14bb2db622d9ee645fea342d9096f8dd3af417d9dbb866f6175d67bd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a060aa2653f4ad692344c5a0fdd4433ce75a0f6f7d8f2f890dea4c76e8aa4b93
MD5 22e604942ba7af20f88b06e1c5d42099
BLAKE2b-256 e8924c6dd0369dfd4310bbc3e34d8a48fb56d74370011e8a811ad65d8f7ae972

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 42b690e9728f07b2fb6aa9b31c77eb24ca9216ed88b520d291c20eceda46b804
MD5 3cd813ad32f716ffc6a22aaf6616c3a3
BLAKE2b-256 ca47af0d54a2e4d0e20a29faadfe9398f567e5e7e658eab0e60cbadfbc7afb27

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.10.0-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.2 CPython/3.9.16

File hashes

Hashes for pytensor-2.10.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 dad90fceed36b96fb6b9c0632031938eed03d0672ed5219eae3804c252431d04
MD5 5398ad0e4b677a8eadcab66e5aa2b3ad
BLAKE2b-256 9201e5cdb62ef5d6b161368d630d6fd4b45e0faa2ab46980cbb10a6d56adaf03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 6122abb15bc564b1f3961c2d687be78f7b375bc6f3df0645ac1f5cd2b9f433a1
MD5 955a5c72fd6b86a26d1a9e9499efd8ca
BLAKE2b-256 1fea0a55b67dfda94ca0182c600910858a64f8388bf81616c3e1edd89b00c411

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 f48988e92fe4581241f5a8f91576bbfc2b5c9f629d2798c81941a8a4fb725bd9
MD5 0bfec7a4ecb5f204513c270ca20eafb0
BLAKE2b-256 431de0873dbf49bab8c654932847ce818236253157aca1bab0bdc52b543cb1cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 71df4f3f32490cdf69b4250dc6d83d30307e866a236a5937ac7bc119c94210a5
MD5 cfefdb3b53cee82982642389f38881dc
BLAKE2b-256 eaa4e9f57b3a60559e69c47c00179596cdf4be805ed4ee651c6f1bfb80d9407e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.10.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 39db23ed9d709bfd30252430d0525c2e1af3e93a8b2b8b565e37781b0f32d9a6
MD5 5495e82f09c857e078ed7f6592620d1d
BLAKE2b-256 ef9d51f25f631d20c5a394f34ca3b9ee2bbcf17f2dd62d6e7f636b15c86f6472

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