Add torch.promote_types function#26655
Closed
nairbv wants to merge 7 commits intogh/nairbv/3/basefrom
Closed
Conversation
[ghstack-poisoned]
[ghstack-poisoned]
gchanan
reviewed
Sep 23, 2019
| promote_types(type1, type2) -> dtype | ||
|
|
||
| Returns the :class:`torch.dtype` with the smallest size and scalar kind to which | ||
| `type1` and `type2` may be safely cast. See type promotion :ref:`documentation <type-promotion-doc>` |
Contributor
There was a problem hiding this comment.
"safely cast" isn't really defined here and I would argue are casting rules aren't really safe (i.e. int32 + float32) -> float32 can lose precision. Can you reword this somehow?
Collaborator
Author
There was a problem hiding this comment.
updated to a more specific explanation.
[ghstack-poisoned]
gchanan
reviewed
Sep 24, 2019
gchanan
approved these changes
Sep 24, 2019
Differential Revision: [D17556196](https://our.internmc.facebook.com/intern/diff/D17556196) [ghstack-poisoned]
Differential Revision: [D17556196](https://our.internmc.facebook.com/intern/diff/D17556196) [ghstack-poisoned]
Differential Revision: [D17556196](https://our.internmc.facebook.com/intern/diff/D17556196) [ghstack-poisoned]
Differential Revision: [D17556196](https://our.internmc.facebook.com/intern/diff/D17556196) [ghstack-poisoned]
zdevito
pushed a commit
to zdevito/ATen
that referenced
this pull request
Sep 28, 2019
Summary: Pull Request resolved: pytorch/pytorch#26655 Test Plan: Imported from OSS Differential Revision: D17556196 Pulled By: nairbv fbshipit-source-id: eeebce8968bfb2ffd25c066595bc19e5dee6ea6f
Contributor
Contributor
|
does this work with JIT? |
Collaborator
Author
Seems like it works as much as scalar types in general work (they're treated as ints): |
pdlive215
pushed a commit
to pdlive215/pytorch
that referenced
this pull request
Nov 27, 2019
Summary: Pull Request resolved: pytorch#26655 Test Plan: Imported from OSS Differential Revision: D17556196 Pulled By: nairbv fbshipit-source-id: eeebce8968bfb2ffd25c066595bc19e5dee6ea6f
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
Summary: Pull Request resolved: pytorch#26655 Test Plan: Imported from OSS Differential Revision: D17556196 Pulled By: nairbv fbshipit-source-id: eeebce8968bfb2ffd25c066595bc19e5dee6ea6f
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.
Stack from ghstack:
Differential Revision: D17556196