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
[Intel MKL] Enable FP32 FusedMatMul for MKL-DNN. #31782
[Intel MKL] Enable FP32 FusedMatMul for MKL-DNN. #31782
Conversation
Can one of the admins verify this patch? |
@Zantares Could you please resolve the conflicts? Thanks! |
Solved, thanks! |
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.
I'm so sorry for the delay! I have mostly minor comments.
|
||
// Do not rewrite with transpose attribute because reorder has performance | ||
// impact. | ||
TF_CHECK_OK(GetNodeAttr(n->def(), "transpose_a", &trans_a)); |
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.
What about transposing B? Are we assuming B is small and would be cheap to reorder?
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.
Input B(weight) can be easily pass to MKL-DNN with different memory desc(io/oi) to represent the transpose attribute. It doesn't need reorder here.
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.
Got it. Thank you for the explanation!
@penpornk thanks for your review, I'll spend 1~2 days to refine the code and ping you once I finish the work:) |
|
||
// Do not rewrite with transpose attribute because reorder has performance | ||
// impact. | ||
TF_CHECK_OK(GetNodeAttr(n->def(), "transpose_a", &trans_a)); |
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.
Got it. Thank you for the explanation!
@Zantares Could you please address Ubuntu Sanity errors? Thanks! |
I've located the failure. It caused by comma missing in BUILD file. Hi @penpornk , I'm sorry that I didn't ping you after refining the code, because I found I can handle the fusion of MatMul, BiasAdd and Relu via reusing code here: https://github.com/tensorflow/tensorflow/pull/31782/files#diff-4e6ad12b109cad067443f126cc8f2145R187. |
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.
If the changes are minor, please feel free to add them to this PR. (I actually found a typo but didn't want to request changes earlier. I might as well request it now.) Otherwise, please open a new PR. :)
const int channel = weight_tf_shape.dim_size(1 - dim_pair[1]); | ||
|
||
OP_REQUIRES(ctx, k == weight_tf_shape.dim_size(dim_pair[1]), | ||
errors::InvalidArgument("Matrix size are incompatible: In[0]: ", |
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.
errors::InvalidArgument("Matrix size are incompatible: In[0]: ", | |
errors::InvalidArgument("Matrix sizes are incompatible: In[0]: ", |
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.
I've reverted the change here because there's a case checking the error verbose like this: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/eager/function_test.py#L270
And no worries about pinging! I saw that you added a commit that addressed all the comments so I assumed the PR is ready for review. Sorry for not waiting until you say so! |
Hi @penpornk , we decide to separate Relu fusion from this PR after internal discussion. Besides, I'v tested Tensorflow UT locally and fixed some errors, please take a look at the new commit, thanks! |
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.
Got it. Thanks again for your PR!
PiperOrigin-RevId: 270955757
Enable FP32 FusedMatMul(MatMul with BiasAdd) for MKL-DNN backend according to below rule:
Also added several cases for testing, moved common code from QuantizedMatMul to an head file.
Modified:
Added:
Signed-off-by: Lu Teng teng.lu@intel.com