DOC: default value of `optimize` in `numpy.einsum`
See original GitHub issueIn the documentation page https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.einsum.html, the default value of optimize
is correctly stated to be False
in the function signature, but erroneously stated to be True
in the parameter description:
optimize : {False, True, ‘greedy’, ‘optimal’}, optional Controls if intermediate optimization should occur. No optimization will occur if False and True will default to the ‘greedy’ algorithm. Also accepts an explicit contraction list from the np.einsum_path function. See np.einsum_path for more details. Default is True.
Reproducing code example:
import timeit
print(timeit.timeit("np.einsum('ea,fb,abcd,gc,hd->efgh', C, C, I, C, C, optimize = True)", 'import numpy as np; I = np.random.rand(10, 10, 10, 10); C = np.random.rand(10, 10)', number = 10))
print(timeit.timeit("np.einsum('ea,fb,abcd,gc,hd->efgh', C, C, I, C, C)", 'import numpy as np; I = np.random.rand(10, 10, 10, 10); C = np.random.rand(10, 10)', number = 10))
The second line should run much slower than the first line.
Numpy/Python version information:
1.15.1 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)]
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
numpy.einsum — NumPy v1.24 Manual
In implicit mode einsum computes these values. ... No optimization will occur if False and True will default to the 'greedy' algorithm.
Read more >Why is the optimize argument False by default in np.einsum?
In the docs of the numpy.einsum (which may be found here) it says that for using optimization may increase calculation of contractions with ......
Read more >numpy.einsum() - JAX documentation - Read the Docs
jax.numpy.einsum(*operands, out=None, optimize='optimal', precision=None, ... which means default precision for the backend, a Precision enum value ...
Read more >torch.einsum — PyTorch 1.13 documentation
For example, matrix multiplication can be computed using einsum as ... differently from NumPy in that it allows dimensions covered by the ellipsis...
Read more >qiskit_nature.settings — Qiskit Nature 0.5.1 documentation
[docs]class QiskitNatureSettings: """Global settings for Qiskit Nature. ... bool: """Returns the setting used for `numpy.einsum(optimize=...)`.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there anything left to do in this issue or can it be closed?
Looks like it would be easier to just fix the documentation for the default value of
optimize
.EDIT: Given how often this issue has come up, probably worth doing.