-
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
[TOPI] Use cblas for dense and batch_matmul when "cblas" is in the target libraries #3787
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2211aac
Support cblas library in dense
jonso4 39618e0
start to add support for generic batch_matmul compute
jonso4 9cf3d17
Add x86 override for batch_matmul
jonso4 1c83dee
Fix linting
jonso4 f4b3baf
reset file
jonso4 b03f4e5
Fix typos
jonso4 575d04e
dummy change to re-trigger CI
jonso4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,34 @@ | |
"""x86 batch_matmul operators""" | ||
from __future__ import absolute_import as _abs | ||
import tvm | ||
from tvm.contrib import cblas | ||
|
||
from topi.nn import batch_matmul, batch_matmul_default | ||
from .. import generic | ||
from ..util import traverse_inline, get_const_tuple, get_max_power2_factor | ||
|
||
@batch_matmul.register(["cpu"]) | ||
def batch_matmul_x86(x, y): | ||
"""Computes batch matrix multiplication of `x` and `y` when `x` and `y` are | ||
data in batch. | ||
|
||
Parameters | ||
---------- | ||
x : tvm.Tensor | ||
3-D with shape [batch, M, K] | ||
|
||
y : tvm.TEnsor | ||
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. same typo 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. Fixed |
||
3-D with shape [batch, N, K] | ||
|
||
Returns | ||
------- | ||
output : tvm.Tensor | ||
3-D with shape [batch, M, N] | ||
""" | ||
target = tvm.target.current_target() | ||
if "cblas" in target.libs: | ||
return cblas.batch_matmul(x, y, False, True) | ||
return batch_matmul_default(x, y) | ||
|
||
@generic.schedule_batch_matmul.register(["cpu"]) | ||
def schedule_batch_matmul(outs): | ||
|
@@ -38,6 +62,10 @@ def schedule_batch_matmul(outs): | |
sch: Schedule | ||
The computation schedule for the op. | ||
""" | ||
target = tvm.target.current_target() | ||
if "cblas" in target.libs: | ||
return generic.schedule_extern(outs) | ||
|
||
s = tvm.create_schedule([x.op for x in outs]) | ||
|
||
def _callback(op): | ||
|
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
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.
type:
y : tvm.Tensor
Please fix the same typo on line 32 as well
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.
Fixed