Created
June 19, 2016 01:44
-
-
Save yukoba/719acfc489018b189840a0b1d9904d83 to your computer and use it in GitHub Desktop.
AutoGrad benchmark of matmul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
import autograd.numpy as np | |
from autograd import grad | |
def fn(a, b): | |
return np.sum(a @ b) | |
n = 1000 | |
a = np.random.rand(n, n) | |
b = np.random.rand(n, n) | |
grad_fn = grad(fn) | |
t = min(timeit.repeat('grad_fn(a, b)', globals=globals(), number=1, repeat=10)) | |
print("grad_fn(a, b) is %d ms" % (t * 1000)) | |
t = min(timeit.repeat('fn(a, b)', globals=globals(), number=1, repeat=10)) | |
print("fn(a, b) is %d ms" % (t * 1000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment