🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixes from review
  • Loading branch information
mattip committed Jun 12, 2025
commit 6100fba37b5f3c9584437d91d5c8c3c219021622
6 changes: 0 additions & 6 deletions doc/release/upcoming_changes/23752.performance.rst

This file was deleted.

4 changes: 4 additions & 0 deletions doc/release/upcoming_changes/29179.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix bug in ``matmul`` for non-contiguous out kwarg parameter
------------------------------------------------------------
In some cases, if ``out`` was non-contiguous, ``np.matmul`` would cause
memory corruption or a c-level assert. This was new to v2.3.0 and fixed in v2.3.1.
6 changes: 6 additions & 0 deletions doc/source/release/2.3.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ the best performance.

(`gh-28769 <https://github.com/numpy/numpy/pull/28769>`__)

Performance improvements for ``np.matmul``
------------------------------------------
Enable using BLAS for ``matmul`` even when operands are non-contiguous by copying
if needed.

(`gh-23752 <https://github.com/numpy/numpy/pull/23752>`__)

Changes
=======
Expand Down
10 changes: 6 additions & 4 deletions numpy/_core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -7272,10 +7272,6 @@ def test_out_contiguous(self):
assert_array_equal(c, tgt_mv)
c = self.matmul(v, a.T, out=out[:, 0, 0])
assert_array_equal(c, tgt_mv)
# issue 29164
out_f = np.zeros((10, 4), dtype=float)
c = self.matmul(a, b, out=out_f[::-2, ::-2])
assert_array_equal(c, tgt)

# test out contiguous in only last dim
out = np.ones((10, 2), dtype=float)
Expand Down Expand Up @@ -7321,6 +7317,12 @@ def test_dot_equivalent(self, args):
r3 = np.matmul(args[0].copy(), args[1].copy())
assert_equal(r1, r3)

# matrix matrix, issue 29164
if [len(args[0].shape), len(args[1].shape)] == [2, 2]:
out_f = np.zeros((r2.shape[0] * 2, r2.shape[1] * 2), order='F')
r4 = np.matmul(*args, out=out_f[::2, ::2])
assert_equal(r2, r4)

def test_matmul_object(self):
import fractions

Expand Down
Loading