Skip to content

Add instance methods tensor.isnan(), tensor.isinf(), tensor.isfinite()#37942

Closed
ShawnZhong wants to merge 1 commit intopytorch:masterfrom
ShawnZhong:instance_methods
Closed

Add instance methods tensor.isnan(), tensor.isinf(), tensor.isfinite()#37942
ShawnZhong wants to merge 1 commit intopytorch:masterfrom
ShawnZhong:instance_methods

Conversation

@ShawnZhong
Copy link
Copy Markdown
Contributor

@ShawnZhong ShawnZhong commented May 6, 2020

Fix #37736

@ShawnZhong ShawnZhong marked this pull request as ready for review May 6, 2020 18:26
@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented May 6, 2020

💊 CI failures summary and remediations

As of commit 341fb19 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

See how this bot performed.

This comment has been revised 9 times.

@choidongyeon
Copy link
Copy Markdown

Hey @ShawnZhong, could you help me understand how this PR fixes the issue? Just curious 😄

@ShawnZhong
Copy link
Copy Markdown
Contributor Author

@choidongyeon

### `variants`
```
variants: function, method
```
Controls whether Tensor method (`t.foo()`) or namespace Function (`at::foo()`) is
generated as a result of this declaration. If the declaration is a method,
you must have an argument `Tensor self` at some position in the method;
in the method variant this argument will be elided from the argument
list. For example, given the declaration `where(BoolTensor cond, Tensor self, Tensor other)`,
this generates the function `at::where(cond, self, other)` and the method
`self.where(cond, other)`.
By default, ATen generates only the function variant for a native function.
When should you also generate a method variant? Tensor operations as methods
are appropriate for "core" Tensor operations (e.g., add, sub, etc.), but not for
more complicated neural network layers (e.g., `conv2d`) and internal functions
designed specifically for binding (e.g., `cudnn_convolution`).
As we progress along our schema unification of the `func` schema with the JIT
signature schema, we must introduce features that allow us to increase compliance.
One of these features are Tensor annotations. As of now we use naming conventions
to indicate whether an argument of a function is going to be mutated and returned.

Update _tensor_docs.py

Update tensors.rst

Update _tensor_docs.py
@ShawnZhong
Copy link
Copy Markdown
Contributor Author

Since this PR has been around for a while, is there anyone who'd like to review this PR?

@gchanan @soumith

Copy link
Copy Markdown
Collaborator

@soumith soumith left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-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.

@soumith is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ShawnZhong ShawnZhong deleted the instance_methods branch May 11, 2020 22:58
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@soumith merged this pull request in 5f9b903.

laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
pytorch#37942)

Summary:
Fix pytorch#37736
Pull Request resolved: pytorch#37942

Differential Revision: D21503150

Pulled By: soumith

fbshipit-source-id: cf6bf57ca67013efe119543f3d9a698473960dec
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.

[discussion] Add convenience instance methods tensor.isnan(), tensor.isinf(), tensor.isfinite()

6 participants