-
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
9e47c62
Add sparse dense end to end model tuning support
jcf94 e477927
Update
jcf94 73b0346
Update
jcf94 9d86fe4
Merge branch 'main' of https://github.com/apache/incubator-tvm into main
jcf94 da3fb50
Lint fix
jcf94 b319eeb
Lint fix
jcf94 c62079c
Lint fix
jcf94 ca43bd3
Merge branch 'main' into sparse_model
jcf94 0206afe
Add sparse tuning for arm network
jcf94 7a708dc
Add sparse support for arm network
jcf94 5d0cc86
Update
jcf94 77941d1
Update
jcf94 cb47cda
Update
jcf94 5379674
Bug fix for tflite frontend dense with layout rewrite
jcf94 8f4fc1d
Move the random_bsr_matrix to sparse.utils
jcf94 46498fb
Update
jcf94 03c455c
Update
jcf94 373020b
Bug fix
jcf94 5325b52
Remove the modification of ARM CPU
jcf94 c032319
Update
jcf94 98de8d8
Update
jcf94 2f030eb
Update
jcf94 a02e98d
Update
jcf94 6c09f8d
Update
jcf94 2b404c8
Update
jcf94 52a1855
Update
jcf94 2a92eeb
Lintfix
jcf94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1872,7 +1872,7 @@ def convert_fully_connected(self, op): | |
out_dtype="int32", | ||
) | ||
else: | ||
out = _op.nn.dense(in_expr, weight_expr) | ||
out = _op.nn.dense(in_expr, weight_expr, units=weight_shape[0]) | ||
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. One small suggestion, if possible, can we add a test case which will indicate the issue fixed here. So that it will help in future breaks. |
||
|
||
# if we have bias | ||
if len(input_tensors) == 3: | ||
|
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
"""Some utils for Sparse operation.""" | ||
|
||
|
||
def random_bsr_matrix(m, n, bs_r, bs_c, density, dtype): | ||
"""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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.