3 ms·
This is on "1536-dimensional vectors", which here means a single vector with 1536 elements, which is really small. In numpy, the way you get performance is to w
by theamk 3y ago
This is on "1536-dimensional vectors", which here means a single vector with 1536 elements, which is really small. In numpy, the way you get performance is to work with much larger blocks, so the Python's overhead is spread across much larger number of elements.
In other words, a loop like this is a huge red flag in any sort of numpy code that is supposed to be performant [0]:
"""Wrap a function to apply it row-wise to rows of two matrices."""
def wrapped(A, B):
for i in range(A.shape[0]):
baseline_func(A[i], B[i])
return wrapped
[0] https://github.com/ashvardanian/SimSIMD/blob/3e51bacb1b74a7ed3fa7bb037162276047192bab/python/bench.py#L196 https://github.com/ashvardanian/SimSIMD/blob/3e51bacb1b74a7e...
- ashvardanian 3y agoThat's precisely my point - the NumPy+Python overhead is quite costly for fine-grained processing :) PS: Those `wrapped` functions aren't used for any reported numbers in the article.