Skip to content

Commit 43095fb

Browse files
authored
add support for order=None in dpnp.einsum (#2411)
Add support for `order=None` for `dpnp.einsum`
1 parent 9b1f5be commit 43095fb

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
* The vector norms `ord={None, 1, 2, inf}` and the matrix norms `ord={None, 1, 2, inf, "fro", "nuc"}` now consistently return zero for empty arrays, which are arrays with at least one axis of size zero. This change affects `dpnp.linalg.norm`, `dpnp.linalg.vector_norm`, and `dpnp.linalg.matrix_norm`. Previously, dpnp would either raise errors or return zero depending on the parameters provided [#2371](https://github.com/IntelPython/dpnp/pull/2371)
2323
* Extended `dpnp.fft.fftfreq` and `dpnp.fft.rfftfreq` functions to support `dtype` keyword per Python Array API spec 2024.12 [#2384](https://github.com/IntelPython/dpnp/pull/2384)
2424
* Updated `dpnp.fix` to return output with the same data-type of input [#2392](https://github.com/IntelPython/dpnp/pull/2392)
25+
* Updated `dpnp.einsum` to add support for `order=None` [#2411](https://github.com/IntelPython/dpnp/pull/2411)
2526

2627
### Fixed
2728

dpnp/dpnp_iface_linearalgebra.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,13 @@ def einsum(
215215
If provided, forces the calculation to use the data type specified.
216216
217217
Default: ``None``.
218-
order : {"C", "F", "A", "K"}, optional
218+
order : {None, "C", "F", "A", "K"}, optional
219219
Controls the memory layout of the output. ``"C"`` means it should be
220220
C-contiguous. ``"F"`` means it should be F-contiguous, ``"A"`` means
221221
it should be ``"F"`` if the inputs are all ``"F"``, ``"C"`` otherwise.
222222
``"K"`` means it should be as close to the layout as the inputs as
223-
is possible, including arbitrarily permuted axes.
223+
is possible, including arbitrarily permuted axes. ``order=None`` is
224+
equivalent to ``order="K"``.
224225
225226
Default: ``"K"``.
226227
casting : {"no", "equiv", "safe", "same_kind", "unsafe"}, optional

dpnp/dpnp_utils/dpnp_utils_einsum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ def dpnp_einsum(
10341034
)
10351035
arrays.append(operands[id])
10361036
result_dtype = dpnp.result_type(*arrays) if dtype is None else dtype
1037-
if order in "aA":
1037+
if order is not None and order in "aA":
10381038
order = "F" if all(arr.flags.fnc for arr in arrays) else "C"
10391039

10401040
input_subscripts = [

dpnp/tests/test_linalg.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,10 @@ def test_output_order(self):
16471647
assert tmp.flags.c_contiguous is False
16481648
assert tmp.flags.f_contiguous is False
16491649

1650+
tmp = dpnp.einsum("...ft,mf->...mt", a, b, order=None, optimize=opt)
1651+
assert tmp.flags.c_contiguous is False
1652+
assert tmp.flags.f_contiguous is False
1653+
16501654
tmp = dpnp.einsum("...ft,mf->...mt", a, b, optimize=opt)
16511655
assert tmp.flags.c_contiguous is False
16521656
assert tmp.flags.f_contiguous is False

0 commit comments

Comments
 (0)