-
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
[CODEGEN] ARM Popcount lowering rule and codegen updates #1235
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0329772
ARM Popcount lowering rule and codegen updates to support reinterpret…
777f9ea
Fixes and test case for arm popcount
2e56f09
white space fixes
2220a36
Merge branch 'master' of https://github.com/dmlc/tvm into low-precision
1d55a8e
unit test fixes and arm codegentest
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import tvm | ||
import re | ||
import os | ||
import ctypes | ||
|
||
def test_popcount(): | ||
target = 'llvm -target=armv7l-none-linux-gnueabihf -mcpu=cortex-a53 -mattr=+neon' | ||
|
||
def check_correct_assembly(type, elements, counts): | ||
n = tvm.convert(elements) | ||
A = tvm.placeholder(n, dtype=type, name='A') | ||
B = tvm.compute(A.shape, lambda i: tvm.popcount(A[i]), name='B') | ||
s = tvm.create_schedule(B.op) | ||
s[B].vectorize(s[B].op.axis[0]) | ||
f = tvm.build(s, [A, B], target) | ||
|
||
# Verify we see the correct number of vpaddl and vcnt instructions in the assembly | ||
assembly = f.get_source('asm') | ||
matches = re.findall("vpaddl", assembly) | ||
assert (len(matches) == counts) | ||
matches = re.findall("vcnt", assembly) | ||
assert (len(matches) == 1) | ||
check_correct_assembly('uint16', 8, 1) | ||
check_correct_assembly('uint16', 4, 1) | ||
check_correct_assembly('uint32', 4, 2) | ||
check_correct_assembly('uint32', 2, 2) | ||
check_correct_assembly('uint64', 2, 3) | ||
|
||
if __name__ == "__main__": | ||
test_popcount() |
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.
We will need a regression test for this rule. please add a test case to arm popcount, to a new file tests/python/unittest/test_codegen_arm.py .
Since we don't have ARM device to verify, what we can do is to dump out the asm file(Maybe we can patch GetSource in llvm module to support get_source("asm") ) and verify the neons sequence is as expected.