@@ -169,7 +169,8 @@ def dot(a, b, out=None):
169
169
170
170
def einsum (* operands , out = None , optimize = False , ** kwargs ):
171
171
"""
172
- einsum(subscripts, *operands, out=None, dtype=None, order="K", casting="safe", optimize=False)
172
+ einsum(subscripts, *operands, out=None, dtype=None, order="K", \
173
+ casting="safe", optimize=False)
173
174
174
175
Evaluates the Einstein summation convention on the operands.
175
176
@@ -190,27 +191,28 @@ def einsum(*operands, out=None, optimize=False, **kwargs):
190
191
If provided, forces the calculation to use the data type specified.
191
192
Default is ``None``.
192
193
order : {"C", "F", "A", "K"}, optional
193
- Controls the memory layout of the output. "C" means it should
194
- be C-contiguous. "F" means it should be F-contiguous,
195
- "A" means it should be "F" if the inputs are all "F", "C" otherwise.
196
- "K" means it should be as close to the layout as the inputs as
194
+ Controls the memory layout of the output. `` "C"`` means it should be
195
+ C-contiguous. `` "F"`` means it should be F-contiguous, ``"A"`` means
196
+ it should be `` "F"`` if the inputs are all `` "F"``, `` "C"`` otherwise.
197
+ `` "K"`` means it should be as close to the layout as the inputs as
197
198
is possible, including arbitrarily permuted axes.
198
199
Default is ``"K"``.
199
200
casting : {"no", "equiv", "safe", "same_kind", "unsafe"}, optional
200
201
Controls what kind of data casting may occur. Setting this to
201
- `"unsafe"` is not recommended, as it can adversely affect accumulations.
202
+ ``"unsafe"`` is not recommended, as it can adversely affect
203
+ accumulations.
202
204
203
205
* ``"no"`` means the data types should not be cast at all.
204
- * ' equiv' means only byte-order changes are allowed.
205
- * "safe" means only casts which can preserve values are allowed.
206
- * "same_kind" means only safe casts or casts within a kind,
206
+ * ``" equiv"`` means only byte-order changes are allowed.
207
+ * `` "safe"`` means only casts which can preserve values are allowed.
208
+ * `` "same_kind"`` means only safe casts or casts within a kind,
207
209
like float64 to float32, are allowed.
208
- * "unsafe" means any data conversions may be done.
210
+ * `` "unsafe"`` means any data conversions may be done.
209
211
210
212
Default is ``"safe"``.
211
213
optimize : {False, True, "greedy", "optimal"}, optional
212
214
Controls if intermediate optimization should occur. No optimization
213
- will occur if ``False`` and ``True`` will default to the "greedy"
215
+ will occur if ``False`` and ``True`` will default to the `` "greedy"``
214
216
algorithm. Also accepts an explicit contraction list from the
215
217
:obj:`dpnp.einsum_path` function. Default is ``False``.
216
218
@@ -381,8 +383,8 @@ def einsum(*operands, out=None, optimize=False, **kwargs):
381
383
larger arrays:
382
384
383
385
>>> a = np.ones(64000).reshape(20, 40, 80)
384
-
385
- Basic `einsum`: 146 ms ± 23.5 ms per loop (benchmarked on 12th
386
+
387
+ Basic `einsum`: 146 ms ± 23.5 ms per loop (benchmarked on 12th
386
388
Gen Intel® Core™ i7-1265U)
387
389
388
390
>>> %timeit -r 10 -n 50 np.einsum("ijk,ilm,njm,nlk,abc->",a,a,a,a,a)
@@ -461,17 +463,17 @@ def einsum_path(*operands, optimize="greedy", einsum_call=False):
461
463
contraction path
462
464
* if ``False`` or ``None`` no optimization is taken
463
465
* if ``True`` defaults to the "greedy" algorithm
464
- * "optimal" is an algorithm that combinatorially explores all possible
465
- ways of contracting the listed tensors and chooses the least costly
466
- path. Scales exponentially with the number of terms in the
467
- contraction.
468
- * "greedy" is an algorithm that chooses the best pair contraction
466
+ * `` "optimal"`` is an algorithm that combinatorially explores all
467
+ possible ways of contracting the listed tensors and chooses the
468
+ least costly path. Scales exponentially with the number of terms
469
+ in the contraction.
470
+ * `` "greedy"`` is an algorithm that chooses the best pair contraction
469
471
at each step. Effectively, this algorithm searches the largest inner,
470
472
Hadamard, and then outer products at each step. Scales cubically with
471
- the number of terms in the contraction. Equivalent to the "optimal"
472
- path for most contractions.
473
+ the number of terms in the contraction. Equivalent to the
474
+ ``"optimal"`` path for most contractions.
473
475
474
- Default is "greedy".
476
+ Default is `` "greedy"`` .
475
477
476
478
Returns
477
479
-------
0 commit comments