-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: working on benchmarks with Finch
as backend
#772
base: main
Are you sure you want to change the base?
Changes from all commits
2b25d4e
ab21082
e6eed2e
f828ba9
f822c24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,16 +15,19 @@ def format_id(format): | |||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
@pytest.mark.parametrize("format", ["coo", "gcxs"]) | ||||||||||||||||||||||||
def test_matmul(benchmark, sides, format, seed, max_size, ids=format_id): | ||||||||||||||||||||||||
def test_matmul(benchmark, sides, seed, format, backend, min_size, max_size, ids=format_id): | ||||||||||||||||||||||||
m, n, p = sides | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if m * n >= max_size or n * p >= max_size: | ||||||||||||||||||||||||
if m * n >= max_size or n * p >= max_size or m * n <= min_size or n * p <= min_size: | ||||||||||||||||||||||||
pytest.skip() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
rng = np.random.default_rng(seed=seed) | ||||||||||||||||||||||||
x = sparse.random((m, n), density=DENSITY, format=format, random_state=rng) | ||||||||||||||||||||||||
y = sparse.random((n, p), density=DENSITY, format=format, random_state=rng) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the tests on file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mtsokol How hard would it be to add this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can probably use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we just need a format=nothing default and then a reformatting line inside finch.random? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That'd suffice -- if the format isn't what the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a way of specifying format currently? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||
if hasattr(sparse, "compiled"): | ||||||||||||||||||||||||
operator.matmul = sparse.compiled(operator.matmul) | ||||||||||||||||||||||||
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
x @ y # Numba compilation | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
@benchmark | ||||||||||||||||||||||||
|
@@ -50,8 +53,12 @@ def elemwise_args(request, seed, max_size): | |||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
@pytest.mark.parametrize("f", [operator.add, operator.mul]) | ||||||||||||||||||||||||
def test_elemwise(benchmark, f, elemwise_args): | ||||||||||||||||||||||||
def test_elemwise(benchmark, f, elemwise_args, backend): | ||||||||||||||||||||||||
x, y = elemwise_args | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if hasattr(sparse, "compiled"): | ||||||||||||||||||||||||
f = sparse.compiled(f) | ||||||||||||||||||||||||
DeaMariaLeon marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
f(x, y) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
@benchmark | ||||||||||||||||||||||||
|
@@ -78,6 +85,10 @@ def elemwise_broadcast_args(request, seed, max_size): | |||||||||||||||||||||||
@pytest.mark.parametrize("f", [operator.add, operator.mul]) | ||||||||||||||||||||||||
def test_elemwise_broadcast(benchmark, f, elemwise_broadcast_args): | ||||||||||||||||||||||||
x, y = elemwise_broadcast_args | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if hasattr(sparse, "compiled"): | ||||||||||||||||||||||||
f = sparse.compiled(f) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
f(x, y) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
@benchmark | ||||||||||||||||||||||||
|
@@ -101,6 +112,9 @@ def test_index_scalar(benchmark, indexing_args): | |||||||||||||||||||||||
side = x.shape[0] | ||||||||||||||||||||||||
rank = x.ndim | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if hasattr(sparse, "compiled"): | ||||||||||||||||||||||||
operator.getitem = sparse.compiled(operator.getitem) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
x[(side // 2,) * rank] # Numba compilation | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
@benchmark | ||||||||||||||||||||||||
|
@@ -113,6 +127,9 @@ def test_index_slice(benchmark, indexing_args): | |||||||||||||||||||||||
side = x.shape[0] | ||||||||||||||||||||||||
rank = x.ndim | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if hasattr(sparse, "compiled"): | ||||||||||||||||||||||||
operator.getitem = sparse.compiled(operator.getitem) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
x[(slice(side // 2),) * rank] # Numba compilation | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
@benchmark | ||||||||||||||||||||||||
|
@@ -126,6 +143,9 @@ def test_index_fancy(benchmark, indexing_args, seed): | |||||||||||||||||||||||
rng = np.random.default_rng(seed=seed) | ||||||||||||||||||||||||
index = rng.integers(0, side, size=(side // 2,)) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if hasattr(sparse, "compiled"): | ||||||||||||||||||||||||
operator.getitem = sparse.compiled(operator.getitem) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
x[index] # Numba compilation | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
@benchmark | ||||||||||||||||||||||||
|
@@ -165,6 +185,9 @@ def densemul_args(request, sides, seed, max_size): | |||||||||||||||||||||||
def test_gcxs_dot_ndarray(benchmark, densemul_args): | ||||||||||||||||||||||||
x, t = densemul_args | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if hasattr(sparse, "compiled"): | ||||||||||||||||||||||||
operator.matmul = sparse.compiled(operator.matmul) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
# Numba compilation | ||||||||||||||||||||||||
x @ t | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.