Skip to content

Conversation

@tunz
Copy link
Contributor

@tunz tunz commented Feb 16, 2018

Hello,
Please take a look.

I implemented torch.isnan in C/C++. You can use this function as following:

>>> torch.isnan(torch.Tensor([1,2,3,float('nan'),5]))

 0
 0
 0
 1
 0
[torch.ByteTensor of size 5]

Since it's my first contribution to your project, I'm not familiar with testing or coding style, so please let me know if something's wrong.

Ref: #4767

@apaszke
Copy link
Contributor

apaszke commented Feb 16, 2018

Thanks for the PR, but can't this be implemented like this (for floating point tensor types):

def isnan(x):
    return x != x

@tunz
Copy link
Contributor Author

tunz commented Feb 16, 2018

Of course, we can implement like that. uploaded a new patch.

@apaszke
Copy link
Contributor

apaszke commented Feb 16, 2018

@pytorchbot test this please

@soumith soumith merged commit cf71385 into pytorch:master Feb 20, 2018
@soumith
Copy link
Contributor

soumith commented Feb 20, 2018

thanks @tunz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants