Skip to content
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

[XLA:CPU] Enable BMM+Mul+Add for bf16 #11241

Closed

Conversation

kanvi-nervana
Copy link
Contributor

This PR enable BatchMatmul + Mul + Add fusion for BF16 and also fixes a bug for the same.

@github-actions github-actions bot added the kokoro:force-run Forces CI to rerun label Apr 5, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Forces CI to rerun label Apr 5, 2024
@kamaljeeti kamaljeeti requested a review from penpornk April 5, 2024 05:37
@kanvi-nervana kanvi-nervana marked this pull request as draft April 5, 2024 19:04
@kanvi-nervana kanvi-nervana marked this pull request as ready for review April 8, 2024 21:27
@github-actions github-actions bot added the kokoro:force-run Forces CI to rerun label May 1, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Forces CI to rerun label May 1, 2024
@kamaljeeti
Copy link
Contributor

Hi @penpornk , @jvstokes , can you please look into this? Thanks.

Copy link
Member

@penpornk penpornk left a 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 PR and I'm sorry for the delay! I have a minor comment.

Comment on lines 387 to 392
if (!IsBatchDot(*dot_instr)) {
if (!IsRowMajor(lhs_shape) || !IsRowMajor(rhs_shape) ||
!IsRowMajor(output_shape)) {
return false;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Let's avoid nested ifs. (Please apply code formatter.)

Suggested change
if (!IsBatchDot(*dot_instr)) {
if (!IsRowMajor(lhs_shape) || !IsRowMajor(rhs_shape) ||
!IsRowMajor(output_shape)) {
return false;
}
}
if (!IsBatchDot(*dot_instr) &&
(!IsRowMajor(lhs_shape) || !IsRowMajor(rhs_shape) ||
!IsRowMajor(output_shape))) {
return false;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@penpornk I made the requested change. Thanks!

@github-actions github-actions bot added the kokoro:force-run Forces CI to rerun label May 7, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Forces CI to rerun label May 7, 2024
Copy link
Member

@penpornk penpornk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you again!

copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request May 8, 2024
Imported from GitHub PR openxla/xla#11241

This PR enable BatchMatmul + Mul + Add fusion for BF16 and also fixes a bug for the same.
Copybara import of the project:

--
abdbf9b89925c8553296122c846327b6dffa86ce by Kanvi Khanna <kanvi.khanna@intel.com>:

Enable BMM+Mul+Add for bf16

--
6674ac76b868f0399731d6185287eec76244df3a by Kanvi Khanna <kanvi.khanna@intel.com>:

fix test

--
8fb80082e8c545e007ab7a2d363eb7b7c251fd07 by Kanvi Khanna <kanvi.khanna@intel.com>:

address review comment, fix test, format

Merging this change closes #11241

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11241 from Intel-tensorflow:kanvi/bmm-mul-add_bf16 8fb80082e8c545e007ab7a2d363eb7b7c251fd07
PiperOrigin-RevId: 631717784
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request May 8, 2024
Imported from GitHub PR openxla/xla#11241

This PR enable BatchMatmul + Mul + Add fusion for BF16 and also fixes a bug for the same.
Copybara import of the project:

--
abdbf9b89925c8553296122c846327b6dffa86ce by Kanvi Khanna <kanvi.khanna@intel.com>:

Enable BMM+Mul+Add for bf16

--
6674ac76b868f0399731d6185287eec76244df3a by Kanvi Khanna <kanvi.khanna@intel.com>:

fix test

--
8fb80082e8c545e007ab7a2d363eb7b7c251fd07 by Kanvi Khanna <kanvi.khanna@intel.com>:

address review comment, fix test, format

Merging this change closes #11241

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11241 from Intel-tensorflow:kanvi/bmm-mul-add_bf16 8fb80082e8c545e007ab7a2d363eb7b7c251fd07
PiperOrigin-RevId: 631717784
@copybara-service copybara-service bot closed this in fdba744 May 8, 2024
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request May 8, 2024
FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11241 from Intel-tensorflow:kanvi/bmm-mul-add_bf16 8fb80082e8c545e007ab7a2d363eb7b7c251fd07
PiperOrigin-RevId: 631306324
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request May 8, 2024
Updates LLVM usage to match
[aefad851672e](llvm/llvm-project@aefad851672e)

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11241 from Intel-tensorflow:kanvi/bmm-mul-add_bf16 8fb80082e8c545e007ab7a2d363eb7b7c251fd07
PiperOrigin-RevId: 631745757
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request May 8, 2024
Imported from GitHub PR openxla/xla#11241

This PR enable BatchMatmul + Mul + Add fusion for BF16 and also fixes a bug for the same.
Copybara import of the project:

--
abdbf9b89925c8553296122c846327b6dffa86ce by Kanvi Khanna <kanvi.khanna@intel.com>:

Enable BMM+Mul+Add for bf16

--
6674ac76b868f0399731d6185287eec76244df3a by Kanvi Khanna <kanvi.khanna@intel.com>:

fix test

--
8fb80082e8c545e007ab7a2d363eb7b7c251fd07 by Kanvi Khanna <kanvi.khanna@intel.com>:

address review comment, fix test, format

Merging this change closes #11241

PiperOrigin-RevId: 631745536
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants