numba/numba

NumbaPerformanceWarning when array is indeed contiguous

Open

#10.086 geöffnet am 27. Mai 2025

Auf GitHub ansehen
 (8 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (1.132 Forks)batch import
feature_requestgood first issuegood second issue

Repository-Metriken

Stars
 (9.177 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 14T 16h) (30 gemergte PRs in 30 T)

Beschreibung

import numpy as np
import numba

@numba.njit
def dot(A, x):
    return np.dot(A, x[:, None])

A = np.ones((5, 5))
x = np.ones((5,))

dot(A, x) 
# <ipython-input-3-5e99dee3597c>:6: NumbaPerformanceWarning: np.dot() is faster on contiguous arrays, called on (Array(float64, 2, 'C', False, aligned=True), Array(float64, 2, 'A', False, aligned=True))
#   return np.dot(A, x[:, None])

Adding a dummy dimension does not make an array non-contiguous. I suspect the warning is either invalid or imprecise.

Contributor Guide