Enables bfloat16 x [float16, complex64, complex128] type promotion#43324
Closed
Enables bfloat16 x [float16, complex64, complex128] type promotion#43324
Conversation
gchanan
reviewed
Aug 20, 2020
| self.assertEqual((bf + scalar).dtype, torch.bfloat16) | ||
| self.assertEqual((scalar + bf).dtype, torch.bfloat16) | ||
| self.assertEqual(scalar + bf, bf + scalar) | ||
| with self.assertRaises(RuntimeError): |
Contributor
There was a problem hiding this comment.
can you add a complex scalar to the for loop above? That seems to capture the intent of this test.
Collaborator
Author
There was a problem hiding this comment.
Good idea. I also simplified the loop.
gchanan
reviewed
Aug 20, 2020
| self.assertEqual(bf + t, t + bf) | ||
| if dtype in (torch.float16, torch.float32, torch.float64, torch.cfloat, torch.cdouble): | ||
| # Handles bfloat16 x float16 -> float32 promotion | ||
| expected_dtype = dtype if dtype != torch.half else torch.float32 |
gchanan
approved these changes
Aug 20, 2020
added 2 commits
August 20, 2020 20:28
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
💊 CI failures summary and remediationsAs of commit f4922f4 (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
Contributor
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
…ytorch#43324) Summary: Implements bfloat16 type promotion consistent with JAX (see https://jax.readthedocs.io/en/latest/type_promotion.html), addressing issue pytorch#43049. - bfloat16 x float16 -> float32 - bfloat16 x complex64 -> complex64 - bfloat16 x complex128 -> complex128 Existing tests, after updates, are sufficient to validate the new behavior. cc xuhdev Pull Request resolved: pytorch#43324 Reviewed By: albanD Differential Revision: D23259823 Pulled By: mruberry fbshipit-source-id: ca9c2c7d0325faced1f884f3c37edf8fa8c8b089
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements bfloat16 type promotion consistent with JAX (see https://jax.readthedocs.io/en/latest/type_promotion.html), addressing issue #43049.
Existing tests, after updates, are sufficient to validate the new behavior.
cc @xuhdev