Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,8 +9,12 @@ import numpy as np
|
|
9 |
print(f"torch_version: {torch.__version__}")
|
10 |
|
11 |
# Define two matrices using NumPy arrays
|
12 |
-
A = np.array([[1, 2], [3, 4]])
|
13 |
-
B = np.array([[5, 6], [7, 8]])
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Start the timer
|
16 |
start_time = time.time()
|
@@ -24,9 +28,14 @@ end_time = time.time()
|
|
24 |
# Calculate and print the time taken
|
25 |
print(f"Time taken for matrix multiplication with NumPy: {end_time - start_time:.6f} seconds")
|
26 |
|
|
|
27 |
# Define two matrices
|
28 |
-
A = torch.tensor([[1, 2], [3, 4]])
|
29 |
-
B = torch.tensor([[5, 6], [7, 8]])
|
|
|
|
|
|
|
|
|
30 |
|
31 |
# Start the timer
|
32 |
start_time = time.time()
|
@@ -43,8 +52,12 @@ print(f"Time taken for matrix multiplication with PyTorch: {end_time - start_tim
|
|
43 |
@spaces.GPU
|
44 |
def zeroGPU_test(text):
|
45 |
# Define two matrices
|
46 |
-
A = torch.tensor([[1, 2], [3, 4]])
|
47 |
-
B = torch.tensor([[5, 6], [7, 8]])
|
|
|
|
|
|
|
|
|
48 |
|
49 |
# Start the timer
|
50 |
start_time = time.time()
|
|
|
9 |
print(f"torch_version: {torch.__version__}")
|
10 |
|
11 |
# Define two matrices using NumPy arrays
|
12 |
+
#A = np.array([[1, 2], [3, 4]])
|
13 |
+
#B = np.array([[5, 6], [7, 8]])
|
14 |
+
|
15 |
+
# Define large matrices
|
16 |
+
A = np.random.rand(1000, 1000) # Random 1000x1000 matrix
|
17 |
+
B = np.random.rand(1000, 1000)
|
18 |
|
19 |
# Start the timer
|
20 |
start_time = time.time()
|
|
|
28 |
# Calculate and print the time taken
|
29 |
print(f"Time taken for matrix multiplication with NumPy: {end_time - start_time:.6f} seconds")
|
30 |
|
31 |
+
|
32 |
# Define two matrices
|
33 |
+
#A = torch.tensor([[1, 2], [3, 4]])
|
34 |
+
#B = torch.tensor([[5, 6], [7, 8]])
|
35 |
+
|
36 |
+
# Define large matrices
|
37 |
+
A = torch.rand(1000, 1000) # Random 1000x1000 matrix
|
38 |
+
B = torch.rand(1000, 1000)
|
39 |
|
40 |
# Start the timer
|
41 |
start_time = time.time()
|
|
|
52 |
@spaces.GPU
|
53 |
def zeroGPU_test(text):
|
54 |
# Define two matrices
|
55 |
+
#A = torch.tensor([[1, 2], [3, 4]])
|
56 |
+
#B = torch.tensor([[5, 6], [7, 8]])
|
57 |
+
|
58 |
+
# Define large matrices
|
59 |
+
A = torch.rand(1000, 1000) # Random 1000x1000 matrix
|
60 |
+
B = torch.rand(1000, 1000)
|
61 |
|
62 |
# Start the timer
|
63 |
start_time = time.time()
|