Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add torch.can_cast(from, to) function#26805

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
nairbv wants to merge3 commits intopytorch:masterfromnairbv:can_cast

Conversation

@nairbv
Copy link
Collaborator

@pytorchbotpytorchbot added module: docsRelated to our documentation, both in docs/ and docblocks module: internalsRelated to internal abstractions in c10 and ATen module: operators labelsSep 25, 2019
@nairbvnairbv added this to the1.3 milestoneSep 25, 2019
@nairbvnairbv mentioned this pull requestSep 25, 2019
@nairbv
Copy link
CollaboratorAuthor

@pytorchbot rebase this please

pytorchbot reacted with thumbs up emoji

Copy link
Contributor

@zou3519zou3519 left a comment

Choose a reason for hiding this comment

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

Are there tests forat::canCast somewhere?


-func:result_type.Scalar_Scalar(Scalar scalar1, Scalar scalar2) -> ScalarType

-func:can_cast(ScalarType from, ScalarType to) -> bool
Copy link
Contributor

Choose a reason for hiding this comment

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

This is removingvariants: function from result_type. However that's the default so it doesn't matter, but I am mentioning that just in case

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

ah didn't notice, that probably happened when I fixed my merge conflict with myself. Interesting that it's the default too.


deftest_can_cast(self):
self.assertTrue(torch.can_cast(torch.double,torch.float))
self.assertFalse(torch.can_cast(torch.float,torch.int))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have unit tests forcanCast (the cpp function) somewhere?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

I don't, do you think it'd be helpful? it's called/used pretty heavily in the actual arithmetic operators and in tensoriterator, which does have a lot of python test coverage.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm ideally we'd unit test heavily-used helper functions likecanCast during development instead of testing them indirectly by testing arithmetic operators so that we can be sure that we're building on top of working code. But since we have all of those tests for arithmetic operators and type promotion this should be fine.

Copy link
Contributor

@facebook-github-botfacebook-github-bot left a comment

Choose a reason for hiding this comment

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

@nairbv is landing this pull request. If you are a Facebook employee, you can view this diffon Phabricator.

zdevito pushed a commit to zdevito/ATen that referenced this pull requestSep 27, 2019
Summary:pytorch/pytorch#25472Pull Requestresolved:pytorch/pytorch#26805Differential Revision: D17628434Pulled By: nairbvfbshipit-source-id: 6af8031ac3afda1505d338075c0637ad043f8b7e
@facebook-github-bot
Copy link
Contributor

@nairbv merged this pull request in2a43b74.

pdlive215 pushed a commit to pdlive215/pytorch that referenced this pull requestNov 27, 2019
Summary:pytorch#25472Pull Requestresolved:pytorch#26805Differential Revision: D17628434Pulled By: nairbvfbshipit-source-id: 6af8031ac3afda1505d338075c0637ad043f8b7e
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@facebook-github-botfacebook-github-botfacebook-github-bot left review comments

@zou3519zou3519zou3519 approved these changes

@gchanangchananAwaiting requested review from gchanan

Assignees

No one assigned

Labels

Mergedmodule: docsRelated to our documentation, both in docs/ and docblocksmodule: internalsRelated to internal abstractions in c10 and ATen

Projects

None yet

Milestone

1.3

Development

Successfully merging this pull request may close these issues.

5 participants

@nairbv@facebook-github-bot@zou3519@pytorchbot@mruberry

[8]ページ先頭

©2009-2025 Movatter.jp