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

Uploaded Source

Built Distributions

pytensor-2.11.1-py2.py3-none-any.whl (3.7 MB view details)

Uploaded Python 2 Python 3

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

pytensor-2.11.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.11.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.11.1-cp310-cp310-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

pytensor-2.11.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.11.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.11.1-cp39-cp39-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

pytensor-2.11.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.11.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.11.1-cp38-cp38-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

pytensor-2.11.1-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.11.1-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.11.1.tar.gz.

File metadata

  • Download URL: pytensor-2.11.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.3

File hashes

Hashes for pytensor-2.11.1.tar.gz
Algorithm Hash digest
SHA256 0999b753eb10e2031e9d3226624a1df4e4e91fb05b9dcbf15533976228129093
MD5 329dae3e653a75ccd73026b93daba7a3
BLAKE2b-256 6d99bb6d8371c9a4bfed297a3c84f3b09103ce334db3bc3482c9302194c54d52

See more details on using hashes here.

File details

Details for the file pytensor-2.11.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pytensor-2.11.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for pytensor-2.11.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d7897114dcb35e9714f3bd8ef7ff0a81e090fdb7e6430b408ed040e3accb26b7
MD5 e4fc707be0a773cf111715d9a03ca3d3
BLAKE2b-256 04ba53e72327c9a08aa2a00aea5edd9d127ba6ee84957e03748289ea635887b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c27e959380d7d5ff36bbca6f0657525683689423cf8df60191aa6eccc3888dd3
MD5 d59b0ce1da434bb8d3e529bc8e5a8f39
BLAKE2b-256 ec7af0f55fb6a1626b92d562fe1b893e73c744a2a134c17f293bc95ca32f6d6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 e30c21200cdb6069840cf89b2f9c9453e81f17883776800741a0504757fbe22d
MD5 f32daea06e2a80b592e43686fecbd55b
BLAKE2b-256 8fdac26deedfc229d5e38ae6070c1a30527806432dc35ad20e9f6916f93f8bd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 d346911e48d57db5f8cbdae44aea0462bceb43caa4bef54739d4ddcc941dd9de
MD5 e3365d07cafb7c76683c040548e7a1df
BLAKE2b-256 1ae2884714f76774a829edf4ae1f261e247954c1897c7205dcb0685c628f5907

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 235918ea53f7fabf872068129eb30c28f16d98c009024b3fd7b3e60f64c0c247
MD5 b3980f95064988e8200e8451065175da
BLAKE2b-256 397f785cda0d8c83dd67bd3625dddb96e106628ac0828c8bf344790c3c37127a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5604911bdd9a491f5cb37f27b8c6b2d9ae4a513248f70603aed2c5db35b68904
MD5 3350ade63d52a0700e9676c8abbe2423
BLAKE2b-256 c1a4ccbf30099b455e3cf45800018de84066e471112610db55a89296bc21e540

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6f77e00c8e9b2cb6ce11d1363d5c044101c2d1a6e0ea6dec22389bf62cfc9079
MD5 fab4473fdfbbb6e8bc1429edd1749d07
BLAKE2b-256 9f5716001540bff033baff8872e0bfe240b2c3f163032621f866a61bd8389c0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 2ed362783825b41148ceafc648039a297d2480b6bac9ac426173dcd76ce12fd8
MD5 d517a409be5fe5203afb6f177a37a5ed
BLAKE2b-256 1bfc6d5a961125143ba1ccf9fdde761ca412196de72d5da8c246966c53ef3915

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 02ba2205b73b1a2e8757033934005324f8dfbafe3eaae0fe8cc0b7bd95d60998
MD5 0b55a2cf25360bca4ab8502653f24390
BLAKE2b-256 5c4c660774459ac62911739ccb3787c85e04facec45c2425e70ebd0087f30095

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b298c17f2fbb51eab665e2ce7a17666fc6f3e9d1bdb6ba011d6df53a43807d67
MD5 040278c20053d35e0561f7b5fc48f11a
BLAKE2b-256 45131ad55893a620fe9832ac83b5e84c195d40fc3d2def7b6adbaae6746e6768

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 197a30c64cd51cda2c3044e056f52eb71ab0f25c45def044435506e3226c4bfc
MD5 2ca58dcb376a725c485b168a99affea8
BLAKE2b-256 46f970f096984e52848d8eee30e44fc6c21e26f62dad4f34947188afd7d468f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.11.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.1 CPython/3.11.3

File hashes

Hashes for pytensor-2.11.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c43516ee7b57123154fa57b4b8af1800180da100b666a2841224d99c29290edf
MD5 6a56b338906ffb32ddaf6d708a46022f
BLAKE2b-256 ab0d67d85a250f573a933f10a54be6143e17332ed6b56a76615315316d0e53d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 b2c2a5c2bfe06c6a562bbcbaf3a29b93ab2d7beffdc9e34a3f047338f786f6d2
MD5 30047964e098fbd71e9215f16bacf54c
BLAKE2b-256 8019c019c6642967063c9e72f9ad939685d3a0b8e0633b7bbcb728bb1c372a39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 ee72af1c0a287e0411a6942caaecb54b5f68e9cd0049cd2423388884372943fe
MD5 5d3e130321697d1de5eea4ea3a9502a3
BLAKE2b-256 68518198457c4dffcc9e5b6deab8a9c7584908974ac1c40f7b54b063828f6408

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c66ec1acdea53e13e1d085c9e41137fc3be7882689df95d53eb7344d6972263a
MD5 f1523b7ae323922dd9b8b39eebefea47
BLAKE2b-256 fda5afe48fb05355407d21fb27cf20b8621094ea048eb13e379800a0d03ada5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0fa55db77c89c70b3ad0f2730062184afb844672c0b6eb0c323be129a5675c4f
MD5 175200a47c7ea93d6d8f24b8b5600364
BLAKE2b-256 66b3c768a570a4cc68e851f66c4810773d54fddb8b680caf14eba0d87bab6e76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.11.1-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.1 CPython/3.11.3

File hashes

Hashes for pytensor-2.11.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 fc1931b161992e8b9a3e8987c8442692688ecab7fa6963af112aa3cf175547fb
MD5 01d5124b8f7a642903c71636d5e2e1f0
BLAKE2b-256 26219801c3013ad93c4a1e48d03e3d0f1950ef5cb5ad26e53ebf9f97a1456730

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 6dc72ff28810060e5453540a4f9accc483f4e59db68df696c2ba35e9777b0edd
MD5 a28184497d9f71cf3fddf587ae129284
BLAKE2b-256 607653508dd6eaa3491f7bf3dd0820e01385cefceee9e0ac54c13e3efe07d38f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 3c70eb8c2ce7676fe156d6c8e2c709bc57fe03e8f9b0534ddd5dd00c1bf4112c
MD5 2007f7c8320b39503f887659affb2623
BLAKE2b-256 9690acd8ca256e3cf1fd66da7e51b2b3fdb0c7ba2ff6e41bdb8cefd04d08935b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45190a992aa1c7bc7f2ec1cdc0882ce046da31b3ff7458bc310133c89e9680ac
MD5 2d4d28922b58a159ae8be097803d90c0
BLAKE2b-256 60f3d11a91fc474c1a51c48606530bd5268bdeb0ec2080928cc8a3b96582022b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 591c5b8ed8d63c5583d67e545048ef009afe27438c34592502f8905192cf6463
MD5 6b3561e1e5f7de243dd31dd273109034
BLAKE2b-256 c582ebbefac2e4e1bc5175230b15d0a527f5cc66bdbf2a2225e0ce0acddb446a

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