-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Added matmul_v2+transpose+reshape fuse pass #36481
Added matmul_v2+transpose+reshape fuse pass #36481
Conversation
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.
Hi, I haven't finish all reviews. Thank you very much for your work !
paddle/fluid/framework/ir/mkldnn/matmul_v2_transpose_reshape_fuse_pass.h
Show resolved
Hide resolved
paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass_tester.cc
Show resolved
Hide resolved
...ddle/fluid/tests/unittests/ir/inference/test_mkldnn_matmul_v2_transpose_reshape_fuse_pass.py
Show resolved
Hide resolved
paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass_tester.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass.cc
Outdated
Show resolved
Hide resolved
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.
Thank you for the contribution!
Maybe you could make some additional fuse tests like it's done in python/paddle/fluid/tests/unittests/mkldnn/test_matmul_mkldnn_op.py:429 ?
paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass.cc
Outdated
Show resolved
Hide resolved
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.
LGTM. Thank you for your contribution Jakub !
paddle/fluid/framework/ir/mkldnn/matmul_v2_transpose_reshape_fuse_pass.cc
Outdated
Show resolved
Hide resolved
python/paddle/fluid/tests/unittests/mkldnn/test_matmul_mkldnn_op.py
Outdated
Show resolved
Hide resolved
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.
LGTM
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.
LGTM
@jczaja please merge this PR |
@jakpiase It is my pleasure to merge your another impactful contribution:) |
def set_op_type(self): | ||
self.op_type = "matmul_v2" | ||
|
||
|
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.
This UT seems inheritate tests of matmul_v1 and did not test matmul_v2 broadcasting with transpose, reshape fuses. So, should matmul_v2 broadcasting case be detected at graph pattern detecting stage and excluded in fuses ? Cause it is not tested.
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.
Hi, I have recently tested it locally with broadcasting(and it works), from what I know this fuse pass is for Ernie model, and there were no broadcasting and I wanted to finish that PR as soon as possible, that's why I have not included that here, if you want I can add these additional broadcasting tests now
Hi @jakpiase @lidanqing-intel , the matmul_v2_transpose_reshape_fuse_pass will get MKLDNNDeviceContext error when turning on GLOG_v, chould you please check it out? You can refer this pr #37416 to reproduce the problem. |
PR types
New features
PR changes
OPs
Describe
Added matmul_v2+transpose+reshape fuse pass(same behavior as matmul+transpose+reshape fuse pass). It is used almost only in BERT-like models but was requested in #36461 as highest priority for 2.2 release