Why this numba code is 6x slower than numpy code?
问题 Is there any reason why the following code run in 2s, def euclidean_distance_square(x1, x2): return -2*np.dot(x1, x2.T) + np.expand_dims(np.sum(np.square(x1), axis=1), axis=1) + np.sum(np.square(x2), axis=1) while the following numba code run in 12s? @jit(nopython=True) def euclidean_distance_square(x1, x2): return -2*np.dot(x1, x2.T) + np.expand_dims(np.sum(np.square(x1), axis=1), axis=1) + np.sum(np.square(x2), axis=1) My x1 is a matrix of dimension (1, 512) and x2 is a matrix of dimension