-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Autoscheduler][Sparse] Add sparse dense end to end model tuning support for x86/arm cpu & Some bug fix #7635
Changes from 7 commits
9e47c62
e477927
73b0346
9d86fe4
da3fb50
b319eeb
c62079c
ca43bd3
0206afe
7a708dc
5d0cc86
77941d1
cb47cda
5379674
8f4fc1d
46498fb
03c455c
373020b
5325b52
c032319
98de8d8
2f030eb
a02e98d
6c09f8d
2b404c8
52a1855
2a92eeb
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 |
---|---|---|
|
@@ -426,7 +426,7 @@ def _process_inputs(input_tensors, m, n, prefix_init): | |
density *= i | ||
density /= k * n | ||
density = density.value | ||
sparse_prefix = "%s_%d_%d_%d_%d_%d_%.2f_" % (prefix_init, m, n, k, bs_r, bs_c, density) | ||
sparse_prefix = "%s_%d_%d_%d_%d_%.2f_" % (prefix_init, n, k, bs_r, bs_c, density) | ||
|
||
visited = set() | ||
|
||
|
@@ -468,3 +468,35 @@ def _traverse(t): | |
sparse_input_map[sparse_indptr] = sparse_prefix + "W_indptr" | ||
|
||
return sparse_input_map | ||
|
||
|
||
def random_bsr_matrix(m, n, bs_r, bs_c, density, dtype): | ||
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. IMO this should not be part of Topi. Either you can put where it is used or I testing. 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.
Fine, just I'm finding that this has been used in many different places. I'll try to find a better postion. 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. Moved 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. I am sorry for such delayed response, i missed your reply somehow. What my suggestion is, random_bsr_matrix() does not qualify to be in Topi unless it is required by some Ops. What i could see it is just utility for Tutorial, so lets keep this utility func in Tutorial file itself. Otherwise we have one more option, we can put it as part of tvm.testing which can help other tutorials and testcases as well. |
||
"""Generate a random sparse matrix in bsr format. | ||
|
||
Returns | ||
------- | ||
scipy.sparse.bsr_matrix | ||
""" | ||
# pylint: disable=import-outside-toplevel | ||
import numpy as np | ||
import itertools | ||
import scipy.sparse as sp | ||
|
||
y = np.zeros((m, n), dtype=dtype) | ||
assert m % bs_r == 0 | ||
assert n % bs_c == 0 | ||
nnz = int(density * m * n) | ||
num_blocks = int(nnz / (bs_r * bs_c)) + 1 | ||
candidate_blocks = np.asarray(list(itertools.product(range(0, m, bs_r), range(0, n, bs_c)))) | ||
assert candidate_blocks.shape[0] == m // bs_r * n // bs_c | ||
chosen_blocks = candidate_blocks[ | ||
np.random.choice(candidate_blocks.shape[0], size=num_blocks, replace=False) | ||
] | ||
# pylint: disable=invalid-name | ||
for (r, c) in chosen_blocks: | ||
y[r : r + bs_r, c : c + bs_c] = np.random.randn(bs_r, bs_c) | ||
s = sp.bsr_matrix(y, blocksize=(bs_r, bs_c)) | ||
assert s.data.shape == (num_blocks, bs_r, bs_c) | ||
assert s.indices.shape == (num_blocks,) | ||
assert s.indptr.shape == (m // bs_r + 1,) | ||
return s |
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.
Lets not hard-code it, we can use the {name + ".data", name + ".indices", name + ".indptr"}
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.
The problem is that we cannot get the "name" during measuring.
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.
Okay, thanks for clarification. But i just wonder if
name
is not available than, how the logic above prefix is working (i mean the line number 98). Its in the same flow right ? Please let me know in case i am mistaken.