Using the code below (in a google colab), I noticed that multiplying a 62x62
with a 62x62
is about 10% slower than multiplying a 64x64
with another 64x64
matrix. Why is this?
import torch
import timeit
a, a2 = torch.randn((62, 62)), torch.randn((62, 62))
b, b2 = torch.randn((64, 64)), torch.randn((64, 64))
def matmuln(c,d):
return c.matmul(d)
print(timeit.timeit(lambda: matmuln(a, a2), number=1000000)) # 13.864160071000015
print(timeit.timeit(lambda: matmuln(b, b2), number=1000000)) # 12.539578468999991