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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pytensor-2.11.3-cp311-cp311-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

pytensor-2.11.3-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.11.3-cp311-cp311-musllinux_1_1_i686.whl (1.7 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

pytensor-2.11.3-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.11.3-cp311-cp311-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pytensor-2.11.3-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

pytensor-2.11.3-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.11.3-cp310-cp310-musllinux_1_1_i686.whl (1.7 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

pytensor-2.11.3-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.11.3-cp310-cp310-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pytensor-2.11.3-cp39-cp39-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

pytensor-2.11.3-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.11.3-cp39-cp39-musllinux_1_1_i686.whl (1.7 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

pytensor-2.11.3-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.11.3-cp39-cp39-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

pytensor-2.11.3-cp38-cp38-musllinux_1_1_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

pytensor-2.11.3-cp38-cp38-musllinux_1_1_i686.whl (1.6 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

pytensor-2.11.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pytensor-2.11.3-cp38-cp38-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d510b09c8c66c4243e42f6c267483c5cb9ae7e257b1db85e2c189f7ce11c19fd
MD5 3574f569e64fcb59ed1d37eab51ca680
BLAKE2b-256 5182cb10704c554cbf50393961dc6b4e1dd967a37ba20f18644aa93cd8bb5873

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 90de0aa0de8d7551a47f7117e9317095628cade60a9a83da97f2ab5da88fb471
MD5 03e281baa69c398878bffb1578672faf
BLAKE2b-256 7178ff188e99b8fefa9a9e0520aed095e24503dc2f5d1acac86a89c7a6db4253

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 da045610e1fb41ba18ca81ecfd6807be22674de666115c67a46de24bc988baac
MD5 f995e62d9ca0eff9022996172caf0562
BLAKE2b-256 45af89dd125c86826d67857bf8ff5de8abfa94a09446fff794577acb27b923f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f6511bda509d7f01dfb631d67698b6845cb219408ddd9df1f7786a8aa963b18b
MD5 aeeebb88a2de77a5c56b0d8e78b2159f
BLAKE2b-256 b2b63bf7f377d6c9d9480970666825700b1ee4d73a17ea9ac8146ef7ea7b2863

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b8024651faed6bb02ac1d2ff9253346543fe394c705ca6069e200c931e921302
MD5 d42cb339f9000e56e6bbc1a91b80f849
BLAKE2b-256 c7994ff813d6d4c85016ca584276b87f5aba283f82b7fb18a6c6322c383d0cd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 308e264b452cd892e555b5538f448f09c2dfac186808ad12f2678d9425a54854
MD5 db1635be9c18865155ff111dfa3b6f72
BLAKE2b-256 5f66d3937e7b449bfd521e5aec0d00e9733244f0db019c8d1b193992f3ebf305

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 539490133691df8a58156f1014c125ae24ec8c6926b4bbbdef4aa80ec62d6ebf
MD5 71bbb36c6ad180839334f865979bc7f0
BLAKE2b-256 f64a41e233b8ebda9ffe49483f00f5b2610de2b61e1e8370646b9d1c51417daa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 77d196927fe9d7a854edd0a5994f22e357166b2bd5aa1b282e51d6488079f311
MD5 46a4f25d80619f2209718165e8cf5d77
BLAKE2b-256 87f6132ccc8510721fa74f138a1564c56b5e0cef1844e0942ffeb16b7c6d906b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ac8f3ad9045390e6b366134ea231033e7cdd4407938b8534b94c62a4ca87a43
MD5 cd89a077010a7d174c8638577a85010f
BLAKE2b-256 af18843e67d1d46bb4334755ad49546a5da7077ae3aaed195e845ef1cdaeed58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6fcfb752c376e126042d044ef9c7c67fdde1d0d80d5733a965aad79873a67eba
MD5 0ab5a18a0db4a675c18ce9804d8d6ab5
BLAKE2b-256 840d4c694d677145547cd373207ba5ac5d41fa182d9e62eaffb3d98e8f744e50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytensor-2.11.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.3 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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d24a048118beb02279b5de3dd61e4078d8b2b59a4b78e813b4aa495822cc659f
MD5 ef91604163fa0986d135896492dc137e
BLAKE2b-256 b682f62ffdbf82a43e77bdce91d834f625bf8120da1cff33536eeae17d9cc0ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 7d7bc91fee4ea3cf3d1d7b773efdddd2c6d3d5df200b76cc661c8cce6c7d65da
MD5 d62a0940b07b01367a6ce5ffe0b770a0
BLAKE2b-256 d1cc5ddeeba1241d893aab770333b10b1da897531f326e8cb21225c176ce548a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 2874eec72d02490cd5e0b32647bd5cd076df31c4956c308a71df61ed1397f5ee
MD5 a9072e11e1c7e07c69e8bf6934dc9d05
BLAKE2b-256 4db48df993686fd3c94dced98fcc8956e36754d007cd712535564588d1e2145a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54740d77ad0fff971cb2871a0dab8287dac5393c94615b3dc7eb718ff1790225
MD5 aa5c54ed36ba0b2aa70f3b3a7c9e47b4
BLAKE2b-256 7057a694e18de02d4007c59282fddc813fe44c78f1044547790f0bd560c0ead7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0b497346e0155e065e9dfe9f6581807b1fc44d79001b9f38a57a084f3c0650c6
MD5 96b589b256636dde0bc09a9491e6b562
BLAKE2b-256 910eb1d7b53705af927f24d64ab87e003c7c834fa127f4350ac8afff433bcdb3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pytensor-2.11.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 523973306c907fe91ae43e52598c7f476f8877a82e7a7fba891803b820a1b034
MD5 512d39e38e4b86c971ad62350425cbfe
BLAKE2b-256 ac2ea8fa78b5a3d65639fc78590f985b838048606f777bd1a36352a6590d09eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 a09d0d766585a916f4f1d5280c61af45e601efca8f9c463030fbab235bdf1d98
MD5 426de8f3aa13dfb23c33edf659dbd88f
BLAKE2b-256 da127ee4731c7890e8a97acf7c5c9e6369a3aa14a1a3e168b76d0ca711d1f6d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 f8fdbe0a3ab7248a1e3cbd400e00e51b9ca1620edaac7d1515dafbbf1141dd3c
MD5 e4680745076a39ae64aec8c71f89990a
BLAKE2b-256 ccb6b5f0a7575c5da2c67016f34ea0a779a2b11ff8c56aaf8b09de6a9b58ad85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e42ef6e6ac8392b7bba508106dcfd9b964656983ec5c5e852dbb2e1de35f41b1
MD5 30cdf3d13049b7c3c905a75e1a492446
BLAKE2b-256 83a0f589ef14040448dc7c97dcd81623b9f7dc84e53363566ef19b8f959f825b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytensor-2.11.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b2d07f691cf9d201e1ee53f90dc8e8f36dffcf922b6f827be3ae6d9c072344a7
MD5 8b12e686d46ad6b2933b10fc88326417
BLAKE2b-256 b00cfbdc97a2783b1d6b5254880704c079a170b97d1aab6ec765d7bcf26727a4

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