{ "info": { "author": "Daniel Smith", "author_email": "dgasmith@icloud.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "[![Build Status](https://travis-ci.org/dgasmith/opt_einsum.svg?branch=master)](https://travis-ci.org/dgasmith/opt_einsum)\n[![codecov](https://codecov.io/gh/dgasmith/opt_einsum/branch/master/graph/badge.svg)](https://codecov.io/gh/dgasmith/opt_einsum)\n[![Anaconda-Server Badge](https://anaconda.org/conda-forge/opt_einsum/badges/version.svg)](https://anaconda.org/conda-forge/opt_einsum)\n[![PyPI](https://img.shields.io/pypi/v/opt_einsum.svg)](https://pypi.org/project/opt-einsum/#description)\n[![Documentation Status](https://readthedocs.org/projects/optimized-einsum/badge/?version=latest)](http://optimized-einsum.readthedocs.io/en/latest/?badge=latest)\n[![DOI](http://joss.theoj.org/papers/10.21105/joss.00753/status.svg)](https://doi.org/10.21105/joss.00753)\n\n\nOptimized Einsum: A tensor contraction order optimizer\n======================================================\n\nOptimized einsum can significantly reduce the overall execution time of einsum-like expressions (e.g.,\n[`np.einsum`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html),\n[`dask.array.einsum`](https://docs.dask.org/en/latest/array-api.html#dask.array.einsum),\n[`pytorch.einsum`](https://pytorch.org/docs/stable/torch.html#torch.einsum),\n[`tensorflow.einsum`](https://www.tensorflow.org/api_docs/python/tf/einsum),\n)\nby optimizing the expression's contraction order and dispatching many\noperations to canonical BLAS, cuBLAS, or other specialized routines. Optimized\neinsum is agnostic to the backend and can handle NumPy, Dask, PyTorch,\nTensorflow, CuPy, Sparse, Theano, JAX, and Autograd arrays as well as potentially\nany library which conforms to a standard API. See the\n[**documentation**](http://optimized-einsum.readthedocs.io) for more\ninformation.\n\n## Example usage\n\nThe [`opt_einsum.contract`](https://optimized-einsum.readthedocs.io/en/latest/autosummary/opt_einsum.contract.html#opt-einsum-contract)\nfunction can often act as a drop-in replacement for `einsum`\nfunctions without futher changes to the code while providing superior performance.\nHere, a tensor contraction is preformed with and without optimization:\n\n```python\nimport numpy as np\nfrom opt_einsum import contract\n\nN = 10\nC = np.random.rand(N, N)\nI = np.random.rand(N, N, N, N)\n\n%timeit np.einsum('pi,qj,ijkl,rk,sl->pqrs', C, C, I, C, C)\n1 loops, best of 3: 934 ms per loop\n\n%timeit contract('pi,qj,ijkl,rk,sl->pqrs', C, C, I, C, C)\n1000 loops, best of 3: 324 us per loop\n```\n\nIn this particular example, we see a ~3000x performance improvement which is\nnot uncommon when compared against unoptimized contractions. See the [backend\nexamples](https://optimized-einsum.readthedocs.io/en/latest/backends.html)\nfor more information on using other backends.\n\n## Features\n\nThe algorithms found in this repository often power the `einsum` optimizations\nin many of the above projects. For example, the optimization of `np.einsum`\nhas been passed upstream and most of the same features that can be found in\nthis repository can be enabled with `np.einsum(..., optimize=True)`. However,\nthis repository often has more up to date algorithms for complex contractions.\n\nThe following capabilities are enabled by `opt_einsum`:\n\n* Inspect [detailed information](http://optimized-einsum.readthedocs.io/en/latest/path_finding.html) about the path chosen.\n* Perform contractions with [numerous backends](http://optimized-einsum.readthedocs.io/en/latest/backends.html), including on the GPU and with libraries such as [TensorFlow](https://www.tensorflow.org) and [PyTorch](https://pytorch.org).\n* Generate [reusable expressions](http://optimized-einsum.readthedocs.io/en/latest/reusing_paths.html), potentially with [constant tensors](http://optimized-einsum.readthedocs.io/en/latest/reusing_paths.html#specifying-constants), that can be compiled for greater performance.\n* Use an arbitrary number of indices to find contractions for [hundreds or even thousands of tensors](http://optimized-einsum.readthedocs.io/en/latest/ex_large_expr_with_greedy.html).\n* Share [intermediate computations](http://optimized-einsum.readthedocs.io/en/latest/sharing_intermediates.html) among multiple contractions.\n* Compute gradients of tensor contractions using [autograd](https://github.com/HIPS/autograd) or [jax](https://github.com/google/jax)\n\nPlease see the [documentation](http://optimized-einsum.readthedocs.io/en/latest/?badge=latest) for more features!\n\n\n## Installation\n\n`opt_einsum` can either be installed via `pip install opt_einsum` or from conda `conda install opt_einsum -c conda-forge`. See the installation [documenation](http://optimized-einsum.readthedocs.io/en/latest/install.html) for further methods.\n\n## Citation\n\nIf this code has benefited your research, please support us by citing:\n\nDaniel G. A. Smith and Johnnie Gray, opt_einsum - A Python package for optimizing contraction order for einsum-like expressions. *Journal of Open Source Software*, **2018**, 3(26), 753\n\nDOI: https://doi.org/10.21105/joss.00753\n\n## Contributing\n\nAll contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome.\n\nA detailed overview on how to contribute can be found in the [contributing guide](https://github.com/dgasmith/opt_einsum/blob/master/.github/CONTRIBUTING.md).", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dgasmith/opt_einsum", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "opt-einsum", "package_url": "https://pypi.org/project/opt-einsum/", "platform": "", "project_url": "https://pypi.org/project/opt-einsum/", "project_urls": { "Homepage": "https://github.com/dgasmith/opt_einsum" }, "release_url": "https://pypi.org/project/opt-einsum/3.1.0/", "requires_dist": null, "requires_python": ">=3.5", "summary": "Optimizing numpys einsum function", "version": "3.1.0" }, "last_serial": 5908920, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "40937646fd421a670e5e93dd21a7aa01", "sha256": "f2090d098388bf8a4fad20410f76ad81db16b9d4bf8c95e6539fca6aee7aa227" }, "downloads": -1, "filename": "opt_einsum-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "40937646fd421a670e5e93dd21a7aa01", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12956, "upload_time": "2016-07-30T22:12:39", "url": "https://files.pythonhosted.org/packages/0a/f4/0c6e221ea86a2cdfc5e7fd2fa99cfe0002a818112d9e066244258d7675f5/opt_einsum-0.2.0-py2.py3-none-any.whl" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "be29ed716ea2e7ad195d4971589adc1a", "sha256": "f8733e18153c6991f203d39b359ddc08f209893648ce56caf8655b0809d5dbd7" }, "downloads": -1, "filename": "opt_einsum-1.0.1.tar.gz", "has_sig": false, "md5_digest": "be29ed716ea2e7ad195d4971589adc1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13633, "upload_time": "2017-07-18T13:43:00", "url": "https://files.pythonhosted.org/packages/4a/29/bddc19c2f10ae2f998fb01173776342ef3bd590cea7ae38da8829bbb7dc6/opt_einsum-1.0.1.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "0c37f770823426d821e15c183b72d333", "sha256": "d991589c4cf82c3581b8c44a33edefe7fc1d245055cf9f3ffbb2299bb29f49dd" }, "downloads": -1, "filename": "opt_einsum-2.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0c37f770823426d821e15c183b72d333", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 29542, "upload_time": "2018-05-17T13:37:41", "url": "https://files.pythonhosted.org/packages/6b/c8/e4c0cd49d054073b704de1d9827386570183b8e91b619b0d7188acf6fbf6/opt_einsum-2.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b15085d33d80be8520da6eec1197fa0e", "sha256": "b1a67039dae6a7d2aa47a522ac19bef381fff53f9b243a50af3827ed9539bfcc" }, "downloads": -1, "filename": "opt_einsum-2.0.0.tar.gz", "has_sig": false, "md5_digest": "b15085d33d80be8520da6eec1197fa0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26771, "upload_time": "2018-05-17T13:37:42", "url": "https://files.pythonhosted.org/packages/de/a2/ae05b691dbd14e2a9ac146ec8a43118f4f681cab09d60b528c3b9bb67b68/opt_einsum-2.0.0.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "1d38a3a2ebba9e1598d0497203437d8c", "sha256": "5d1b9ba61829dc35e30971a926e0c12a378009f58a1962c558e776908d27f0f8" }, "downloads": -1, "filename": "opt_einsum-2.1.1.tar.gz", "has_sig": false, "md5_digest": "1d38a3a2ebba9e1598d0497203437d8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33257, "upload_time": "2018-08-14T22:06:08", "url": "https://files.pythonhosted.org/packages/30/52/64ed28228334a1124c082809402c01c4219085c5ee0f34991ace24a10dad/opt_einsum-2.1.1.tar.gz" } ], "2.1.2": [ { "comment_text": "", "digests": { "md5": "6dfe5602136c196e6104fae17316e44b", "sha256": "815fbb96d60edb10087c0bd80128d11116c374582ac489050cf31928195278d0" }, "downloads": -1, "filename": "opt_einsum-2.1.2.tar.gz", "has_sig": false, "md5_digest": "6dfe5602136c196e6104fae17316e44b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49511, "upload_time": "2018-08-15T20:41:22", "url": "https://files.pythonhosted.org/packages/36/24/97005b8d821e798ed68957b297595f161c22f2f31107703c0433e98195c5/opt_einsum-2.1.2.tar.gz" } ], "2.1.3": [ { "comment_text": "", "digests": { "md5": "c539ce6953a9d99431e2415a11825f4c", "sha256": "fedbe085b2473f579116e4d10d109b29d7c0d1234215a2af7e03e147954c6f69" }, "downloads": -1, "filename": "opt_einsum-2.1.3.tar.gz", "has_sig": false, "md5_digest": "c539ce6953a9d99431e2415a11825f4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49755, "upload_time": "2018-08-23T22:14:11", "url": "https://files.pythonhosted.org/packages/84/f4/aed2ebbb710a3aa172cdf9dc849e8ce38e0df984c6e683fbbc1537942be7/opt_einsum-2.1.3.tar.gz" } ], "2.2.0": [ { "comment_text": "", "digests": { "md5": "7255c808347d178a486e2cd0174fe47f", "sha256": "48d384956f408db32d17a6f3fd8a0261d1e17de71dd061e0300f6fc49b7ddc6d" }, "downloads": -1, "filename": "opt_einsum-2.2.0.tar.gz", "has_sig": false, "md5_digest": "7255c808347d178a486e2cd0174fe47f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 54637, "upload_time": "2018-08-29T22:24:44", "url": "https://files.pythonhosted.org/packages/fa/b8/cc2d20fe4f3bcad9c1bb142fa7105229aa30585a095d6c7aa8f2f19a05b4/opt_einsum-2.2.0.tar.gz" } ], "2.3.1": [ { "comment_text": "", "digests": { "md5": "e6d35a1e93ef33db818d8b6474eaf5de", "sha256": "e24f369b2e8ad72a150c23c71bb0ddbdde2e03f487600a050c6cd323c84056d5" }, "downloads": -1, "filename": "opt_einsum-2.3.1.tar.gz", "has_sig": false, "md5_digest": "e6d35a1e93ef33db818d8b6474eaf5de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 59466, "upload_time": "2018-12-01T16:24:36", "url": "https://files.pythonhosted.org/packages/70/de/3ba1fd12f861c1c4126720a9abd4b6d4d81282e2ee93ac1b1667cb83153f/opt_einsum-2.3.1.tar.gz" } ], "2.3.2": [ { "comment_text": "", "digests": { "md5": "03e4da99bfcb8606b3f783777b01e755", "sha256": "d3d464b4da7ef09e444c30e4003a27def37f85ff10ff2671e5f7d7813adac35b" }, "downloads": -1, "filename": "opt_einsum-2.3.2.tar.gz", "has_sig": false, "md5_digest": "03e4da99bfcb8606b3f783777b01e755", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 59489, "upload_time": "2018-12-09T20:40:30", "url": "https://files.pythonhosted.org/packages/f6/d6/44792ec668bcda7d91913c75237314e688f70415ab2acd7172c845f0b24f/opt_einsum-2.3.2.tar.gz" } ], "3.0.1": [ { "comment_text": "", "digests": { "md5": "75e6702546b34843bd0e3d6ab924067d", "sha256": "8aba07af4cf80e86ec57a0fcc0d36267a37e15a19fbdcf8734ed836e04defea9" }, "downloads": -1, "filename": "opt_einsum-3.0.1.tar.gz", "has_sig": false, "md5_digest": "75e6702546b34843bd0e3d6ab924067d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 66204, "upload_time": "2019-08-22T13:11:31", "url": "https://files.pythonhosted.org/packages/c0/1a/ab5683d8e450e380052d3a3e77bb2c9dffa878058f583587c3875041fb63/opt_einsum-3.0.1.tar.gz" } ], "3.1.0": [ { "comment_text": "", "digests": { "md5": "7cd76dc8874040fe95a046e7676c5811", "sha256": "edfada4b1d0b3b782ace8bc14e80618ff629abf53143e1e6bbf9bd00b11ece77" }, "downloads": -1, "filename": "opt_einsum-3.1.0.tar.gz", "has_sig": false, "md5_digest": "7cd76dc8874040fe95a046e7676c5811", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 69421, "upload_time": "2019-09-30T20:53:31", "url": "https://files.pythonhosted.org/packages/b8/83/755bd5324777875e9dff19c2e59daec837d0378c09196634524a3d7269ac/opt_einsum-3.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7cd76dc8874040fe95a046e7676c5811", "sha256": "edfada4b1d0b3b782ace8bc14e80618ff629abf53143e1e6bbf9bd00b11ece77" }, "downloads": -1, "filename": "opt_einsum-3.1.0.tar.gz", "has_sig": false, "md5_digest": "7cd76dc8874040fe95a046e7676c5811", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 69421, "upload_time": "2019-09-30T20:53:31", "url": "https://files.pythonhosted.org/packages/b8/83/755bd5324777875e9dff19c2e59daec837d0378c09196634524a3d7269ac/opt_einsum-3.1.0.tar.gz" } ] }