-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'clean-up' into optimize-sap
- Loading branch information
Showing
8 changed files
with
39 additions
and
37 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
import numpy as np | ||
from benchmark import benchmark, format_mean_std | ||
from mops.reference_implementations import ( | ||
sparse_accumulation_scatter_add_with_weights as ref_sasax, | ||
) | ||
|
||
from mops import sparse_accumulation_scatter_add_with_weights as sasax | ||
|
||
# from mops.reference_implementations import ( | ||
# sparse_accumulation_scatter_add_with_weights as ref_sasax, | ||
# ) | ||
|
||
np.random.seed(0xDEADBEEF) | ||
|
||
A = np.random.rand(100, 20) | ||
R = np.random.rand(100, 200) | ||
X = np.random.rand(25, 13, 200) | ||
C = np.random.rand(50) | ||
I = np.random.randint(25, size=(100,)) | ||
J = np.random.randint(25, size=(100,)) | ||
n_O = 15 | ||
M_1 = np.random.randint(20, size=(50,)) | ||
M_2 = np.random.randint(13, size=(50,)) | ||
M_3 = np.random.randint(n_O, size=(50,)) | ||
A = np.random.rand(60000, 13) | ||
R = np.random.rand(60000, 32) | ||
X = np.random.rand(1000, 7, 32) | ||
C = np.random.rand(900) | ||
I = np.random.randint(1000, size=(60000,)) | ||
J = np.random.randint(1000, size=(60000,)) | ||
n_O = 100 | ||
M_1 = np.random.randint(13, size=(900,)) | ||
M_2 = np.random.randint(7, size=(900,)) | ||
M_3 = np.random.randint(n_O, size=(900,)) | ||
|
||
ref_mean, ref_std = benchmark(lambda: ref_sasax(A, R, X, C, I, J, M_1, M_2, M_3, n_O)) | ||
# ref_mean, ref_std = benchmark( | ||
# lambda: ref_sasax(A, R, X, C, I, J, M_1, M_2, M_3, n_O), repeats=3, warmup=1 | ||
# ) # very slow | ||
mean, std = benchmark(lambda: sasax(A, R, X, C, I, J, M_1, M_2, M_3, n_O)) | ||
|
||
print("Reference implementation:", format_mean_std(ref_mean, ref_std)) | ||
# print("Reference implementation:", format_mean_std(ref_mean, ref_std)) | ||
print("Optimized implementation:", format_mean_std(mean, std)) | ||
|
||
print("Speed-up:", ref_mean / mean) | ||
# print("Speed-up:", ref_mean / mean) |
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
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