Last active
October 31, 2022 20:48
-
-
Save plmi/38e9d1c1d074413b61adaf6d6ae0ade8 to your computer and use it in GitHub Desktop.
FLOP Benchmark with numpy
This file contains hidden or 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
#!/usr/bin/env python3 | |
import time | |
import numpy as np | |
N = 4096 | |
A = np.random.randn(N, N).astype(np.float32) | |
B = np.random.randn(N, N).astype(np.float32) | |
# number of multiplications | |
flop = N*N*2*N | |
for i in range(10): | |
start_time = time.monotonic() | |
C = A @ B | |
end_time = time.monotonic() | |
time_diff = end_time - start_time | |
print(f"{flop / time_diff * 1e-12:.2f} TFLOP/S") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On a Thinkpad T440p with an i7-4800MQ I get: