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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

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

Uploaded CPython 3.11 macOS 10.9+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

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

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

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

Uploaded CPython 3.9 macOS 10.9+ x86-64

pytensor-2.9.1-cp38-cp38-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.8 Windows x86-64

pytensor-2.9.1-cp38-cp38-musllinux_1_1_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

pytensor-2.9.1-cp38-cp38-musllinux_1_1_i686.whl (4.2 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

pytensor-2.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pytensor-2.9.1-cp38-cp38-macosx_10_9_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pytensor-2.9.1-cp37-cp37m-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.7m Windows x86-64

pytensor-2.9.1-cp37-cp37m-musllinux_1_1_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

pytensor-2.9.1-cp37-cp37m-musllinux_1_1_i686.whl (4.0 MB view details)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

pytensor-2.9.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pytensor-2.9.1-cp37-cp37m-macosx_10_9_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: pytensor-2.9.1.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.9.1.tar.gz
Algorithm Hash digest
SHA256 b5a50203dd247ab887929adcfe2f812624e3ce07821fe530fdfc1ed553abbb58
MD5 decfbf48d24cd968f35acf9089513535
BLAKE2b-256 a70d621c9aaf5406a39b2defa66cedc2d54a377b0524b360de0c282668b3f57d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 982d19b714c85ff745d9d13f28878538a302a58c30be3bedecd009c3093a4e10
MD5 f35f7134f8e943fc3b8575dcfcf4be6c
BLAKE2b-256 b6a8499b28f9cefd77ea32c9c8cba6d87a8b0c4532e4bb3f8c09536910f2d25f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 e9294ed3fa719d2cf80537f86657dfd344d271bbf4206fe506b0ec022edcdc69
MD5 6a180703b95b384d2f9a9d0b4e12a54f
BLAKE2b-256 de3715a139ad4de27c3e4d8f25fa27d6db8d4902b297f1f0ae7fcf192a0f6442

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 65a08bdd217228fc80b9d0cfc47f0d314ad3a3bb1ed0851ff698df7ef3b45427
MD5 4c632d3f097950c0cbbd2aaefed8be12
BLAKE2b-256 786fd70b2d4c21251f8262cdab8e5fd263886d4942b1a724b6a1ac47ecab34a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e914c667606518889fcd07faa8e7228c14738f0bbf1c81b6875ea4b2bab7bb61
MD5 0ef3b35f1eb29bbf53a7118d0ddc2a76
BLAKE2b-256 a1ea5f4d8a363842a603d005d3ac207763cd6cedd847892f91d568809ef617b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d389f5f0c2ff97871876bd86d4ae4d4d06a6e28654c4e8740798df8bd7ec0b24
MD5 beb6c016d60f7ca574b42391264f1519
BLAKE2b-256 a01611fb80b3c1fee01aa93aea8afce236c7a4d7ac2b423d8946eba7567e9be8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bb38b3e68d1c61989855e7a119068bd9e3f7c1a5e3ff3a1fbd755281d9f030e5
MD5 f374fb4e0325e7c3c9639d8088c977a6
BLAKE2b-256 dbbce00856fa3c04f1e1cbce434342ba51ae60ca067f6cd7eacc34185df19365

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 a41fab812d40381a9158a307885d3e2c71e1e2fcbbd193e4a05f1b7b6bf01b0c
MD5 320c9780509a2c36d6926abb34409ade
BLAKE2b-256 2b89da9172e7e986d0bb7b11157a8fc3cfd14167b25e8751d2ce2039e220caa3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 456eca8faf7b53ad474ec2c01dacb195db2d9b920b3714b3465fc61911aa0a39
MD5 3b0f9bd6e5fb380807627198735ac03f
BLAKE2b-256 cd1f91f7cce8f32432b5038df3254dfdf21632619949d195da28468ae7a76bde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6557f68057d7c582bc8ddebd4d6d5c6e79baa402805bba2f402d9ed50da81483
MD5 d8c353f331e31027c9262c971c2b35a2
BLAKE2b-256 e0b2d8920f42356ad588bad2c23a97c63cade682039be0a330d237b4690c1c4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9f7fc7fb2dcd7c96a4312b3ac602b51eb050fb9a86016942decda86338e6c212
MD5 fcb1bf839942e397be755cda6560ec73
BLAKE2b-256 d3ade1f65f4a52a40632795c677df3613f393251cfc779107f3abf3b7fb2537a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.9.1-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.9.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 59aba3890b0770d56ac5793ddd36aac7255a03326795804b755c31200e5c1a3b
MD5 d0c3c86e9c6c4ec087d8297632aae87a
BLAKE2b-256 a555968dd42fec5431fe11e45929f7227d1e752708d9e957eddbcbd7fcf4f0e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 fadde7d42c04a700db82df139178f71889ef09f1c2cab317db17a7c463198fd0
MD5 cf3bbe4ea5f566a71f6063a2c89ed370
BLAKE2b-256 74ef34c29e078e91c2eab565b467839430e9db027d1990f9a14250d9dcbbbae5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 07997cc6bff07e081eeff670ac3f0c91b4f4efadfd23af3311cf8f231a440f5f
MD5 be650114a0cf5056e1151e0d7a73a472
BLAKE2b-256 0ba48cf370b3f5c6098475de026304d69e87cda8323485aab7c86dfaa3927cf0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2fb7edbd8ef664ec7732eb86cf2a1f46f764e4b0b19200366bee215080609d18
MD5 22c14c303ceabdd7abb10c2f4578554b
BLAKE2b-256 467ad8fa064565e51ecb90976ff826b6e698884df88789c1d787380b3be031cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5ba507c087db13b14475cb96e08aea8077dc882ef21e878392268944d8e87cfa
MD5 b343911405e77d02ba6ecfdf7382c3da
BLAKE2b-256 38d34cca7e27d0aa85e9a3c821ffd2986aebdb8ef3e754d4f5342fd0ec596adf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.9.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 3.8 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.9.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 48416e8843f3ab2c2bc913adf93ba6dd736856951eb3573ebe5373e093d2edf8
MD5 74fd424ee86043a2e7053e7c51493c9c
BLAKE2b-256 58cd425c5c1d1a0db22908215e3d6f3f3f3ea16458a87614715ae6c9fcb38547

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 647a9952156ef347512a64163031ce5418d95f764437a9075c3ddeeeebe396ee
MD5 da2a6b34b0c62f00fdc8c18191f7a084
BLAKE2b-256 7c98a06b71aaeb97ecc880698102db5677660c4d11959c1f8b01f6e2dcfe20f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 277a71feeede0e4e0b4a60678ef1569581f45507e3e9bcc453c2fbd29d0a7faf
MD5 d9a4cfe46e377186ac4eb357ea02eabd
BLAKE2b-256 e37e3cb79f8c8de007171376afb7e3f76e43b8557ecb429aab7bf3f911ba7e6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e83903f405283f1b750829beafe7e7fdbc59e8a09e31cf63e721ee0a994be1e
MD5 7cbad097c5fea9e9ab2dea1894087d8a
BLAKE2b-256 212fa0c876641f833d3037381f554bea85cfea51b861c79e6b8e7386401fe35f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.9.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c22f92c959b34ef44fe138ef1d13448ac80e7b7483e7f2e9735cfb56badd4423
MD5 3533ce38a39ab7eab550f4f181853f76
BLAKE2b-256 783f08260ed3ecddebbbc4a4bd7e7ef5ac5a7a0b68442a73eb284b756e58aea8

See more details on using hashes here.

File details

Details for the file pytensor-2.9.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pytensor-2.9.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pytensor-2.9.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 4c3b828eaa4556fa62ae066c352dbb36275c195e547654b4129eaba1ab6b1861
MD5 1dcb235f36efa36da4d2c301d38b8fc5
BLAKE2b-256 dc0e6ec5bb7c7187219a81ee86ae74eadcb1ae1b01e9f2c65e8cdbda497e1a49

See more details on using hashes here.

File details

Details for the file pytensor-2.9.1-cp37-cp37m-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.9.1-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 d6dbf86c115a2e726f30e50bedd428ab68eebb69b4ac33664a4e1d83069d41f5
MD5 666657c183d96d813be7c4a36e58624d
BLAKE2b-256 7c9827c2233b057766732ebbc307d9d7b3f1469c36982c8538b8dc4d7a5118f2

See more details on using hashes here.

File details

Details for the file pytensor-2.9.1-cp37-cp37m-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for pytensor-2.9.1-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 94ceffea282bd0b214153df4cd5585fb937bdb34ac6c2aa05413e25a55827009
MD5 bd3bbcf11fa206bfa065bd838ed52363
BLAKE2b-256 91f806f8fd78ea55c8efb7ba6f0057145cb585c09faf0463e43b17cb5b20fdba

See more details on using hashes here.

File details

Details for the file pytensor-2.9.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.9.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fd551630be8a8c03d6c382989e871139b979247cfa38d8ca63194b78cc4a94b7
MD5 5f53dff69b02e51bdb000d9edb479b63
BLAKE2b-256 674e4591df676b7b37d958f15e403547b5e2ab144519d739cac7d74bf4046cdb

See more details on using hashes here.

File details

Details for the file pytensor-2.9.1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pytensor-2.9.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5c516a1143322b4608ef60fa640e92b1a5ff7288d3b3559aacb958e949fd8588
MD5 30b05e470f5365207586064623575aec
BLAKE2b-256 67a364dfe8014875dd1c3757062eae27ec82bbdf4d29d46d1e5fd65b00b051b5

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