1
0
This commit is contained in:
2024-05-23 20:43:52 +08:00
parent e6da567437
commit 9a33bd6f49
11 changed files with 292 additions and 1 deletions

29
test/performance.py Normal file
View File

@@ -0,0 +1,29 @@
import torch
import time
print(torch.__version__)
print(torch.backends.mps.is_available())
print(torch.cuda.is_available())
a = torch.randn(10000,1000)
b = torch.randn(1000,2000)
t0 = time.time()
c = torch.matmul(a, b)
t1 = time.time()
print(a.device,t1-t0,c.norm(2))
device = torch.device('mps')
a = a.to(device)
b = b.to(device)
t0 = time.time()
c = torch.matmul(a, b)
t1 = time.time()
print(a.device,t1-t0,c.norm(2))
t0 = time.time()
c = torch.matmul(a, b)
t1 = time.time()
print(a.device,t1-t0,c.norm(2))