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