Numba повышает предупреждение о производительности при использовании @, массивы Eventhough являются смежными - PullRequest
0 голосов
/ 03 января 2019

Я делаю простое скалярное произведение между столбцом массива Фортрана и строкой массива Си (так что оба они непрерывны в памяти).

import numpy as np

from numba import njit


@njit
def do_dot():
    X = np.asfortranarray(np.ones((3, 4)))
    B = np.ones((4, 5))

    X[:, 0:1] @ B[0:1, :]


def test_warning():
    do_dot()

Однако я получаю предупреждение:

➜  tests/ ✗ pytest test_numba.py
============================================================= test session starts =============================================================
platform linux -- Python 3.6.6, pytest-4.0.2, py-1.5.3, pluggy-0.7.1
rootdir: /home, inifile:
plugins: cov-2.6.0
collected 1 item                                                                                                                              

test_numba.py .                                                                                                                         [100%]

============================================================== warnings summary ===============================================================
tests/test_numba.py::test_warning
  /home/test_numba.py:11: PerformanceWarning: '@' is faster on contiguous arrays, called on (array(float64, 2d, A), array(float64, 2d, A))
    X[:, 0:1] @ B[0:1, :]
  /home/me/anaconda3/lib/python3.6/site-packages/numba/typing/npydecl.py:965: PerformanceWarning: '@' is faster on contiguous arrays, called on (array(float64, 2d, A), array(float64, 2d, A))
    % (self.func_name, (a, b)), PerformanceWarning)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
==================================================== 1 passed, 2 warnings in 0.69 seconds ==========================

Кроме того, предупреждения появляются, только если тест проходит через pytest: запуск do_dot() непосредственно в оболочке python не вызывает никакого предупреждения.

В чем может быть причина?

Редактировать : версия numba - 0.41.0

...