From eef95e0e9ac243df19d94bb006e3fcb9e7edf781 Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Wed, 7 Aug 2019 17:38:34 +0200 Subject: [PATCH] Add pystencils.autodiff --- README.md | 1 + pystencils/__init__.py | 7 +++++++ pystencils/autodiff.py | 14 ++++++++++++++ setup.py | 1 + 4 files changed, 23 insertions(+) create mode 100644 pystencils/autodiff.py diff --git a/README.md b/README.md index 4aebd6a6f..d079128a5 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ All options: - `alltrafos`: pulls in additional dependencies for loop simplification e.g. libisl - `bench_db`: functionality to store benchmark result in object databases - `interactive`: installs dependencies to work in Jupyter including image I/O, plotting etc. +- `autodiff`: enable derivation of adjoint kernels and generation of Torch/Tensorflow operations - `doc`: packages to build documentation Options can be combined e.g. diff --git a/pystencils/__init__.py b/pystencils/__init__.py index a7e21703b..45ffeab52 100644 --- a/pystencils/__init__.py +++ b/pystencils/__init__.py @@ -13,6 +13,13 @@ from .simp import AssignmentCollection from .slicing import make_slice from .sympyextensions import SymbolCreator +try: + import pystencils_autodiff + autodiff = pystencils_autodiff +except Exception: + pass + + __all__ = ['Field', 'FieldType', 'fields', 'TypedSymbol', 'make_slice', diff --git a/pystencils/autodiff.py b/pystencils/autodiff.py new file mode 100644 index 000000000..af9469bc2 --- /dev/null +++ b/pystencils/autodiff.py @@ -0,0 +1,14 @@ +""" +Provides tools for generation of auto-differentiable operations. + +See https://github.com/theHamsta/pystencils_autodiff + +Installation: + +.. code-block:: bash + pip install pyconrad-autodiff +""" +import os + +if 'CI' not in os.environ: + raise NotImplementedError('pystencils-autodiff is not installed. Run `pip install pystencils-autodiff`') diff --git a/setup.py b/setup.py index ebf2859b3..6a926c30e 100644 --- a/setup.py +++ b/setup.py @@ -108,6 +108,7 @@ setup(name='pystencils', 'alltrafos': ['islpy', 'py-cpuinfo'], 'bench_db': ['blitzdb', 'pymongo', 'pandas'], 'interactive': ['matplotlib', 'ipy_table', 'imageio', 'jupyter', 'pyevtk'], + 'autodiff': ['pystencils-autodiff'], 'doc': ['sphinx', 'sphinx_rtd_theme', 'nbsphinx', 'sphinxcontrib-bibtex', 'sphinx_autodoc_typehints', 'pandoc'], }, -- GitLab