numba raises performance warning when using @, eventhough array are contiguous

Viewed 2602

I do a simple dot product between a column of a Fortran array, and a line of a C array (so both are contiguous in memory).

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()

However, I get a warning:

āžœ  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 ==========================

Additionally, the warnings appear only if the test is ran through pytest: running do_dot() directly in a python shell does not raise any warning.

What could be the cause ?

Edit: numba version is 0.41.0

0 Answers
Related