Skip to content

Conversation

@SplitInfinity
Copy link

@SplitInfinity SplitInfinity commented Sep 23, 2020

Stack from ghstack:

Summary
This commit updates the TorchScript language reference to include
documentation on recently-added TorchScript enums. It also removed
torch.no_grad from the list of known unsupported torch modules and
classes because it is now supported.

Test Plan
Continuous integration.

Differential Revision: D23971884

**Summary**
This commit updates the TorchScript language reference to include
documentation on recently-added TorchScript enums. It also removed
`torch.no_grad` from the list of known unsupported `torch` modules and
classes because it is now supported.

**Test Plan**
Continuous integration.

[ghstack-poisoned]
@SplitInfinity
Copy link
Author

Where's a good place to mention property support? They're not part of the core Python language so jit_python_reference.rst is not the right place to put documentation about them. A new section in jit_language_reference.rst, maybe?

* :class:`torch.nn.RNN`
* :class:`torch.nn.AdaptiveLogSoftmaxWithLoss`
* :class:`torch.autograd.Function`
* :class:`torch.autograd.no_grad`
Copy link
Author

Choose a reason for hiding this comment

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

Is there a good place to mention that record_function is supported now?

@dr-ci
Copy link

dr-ci bot commented Sep 23, 2020

💊 CI failures summary and remediations

As of commit 5b009a6 (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 or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 22 times.

**Summary**
This commit updates the TorchScript language reference to include
documentation on recently-added TorchScript enums. It also removed
`torch.no_grad` from the list of known unsupported `torch` modules and
classes because it is now supported.

**Test Plan**
Continuous integration.

[ghstack-poisoned]
**Summary**
This commit updates the TorchScript language reference to include
documentation on recently-added TorchScript enums. It also removed
`torch.no_grad` from the list of known unsupported `torch` modules and
classes because it is now supported.

**Test Plan**
Continuous integration.

[ghstack-poisoned]
Copy link
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

Looks good, a couple comments


.. warning::

TorchScript enum support is experimental..
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we don't need to mark it as experimental - there may be bugs but that's true of everything else too 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

lol



.. _TorchScript Enums:
.. _TorchScript Enums:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the triple repeat here intentional?

Copy link
Author

Choose a reason for hiding this comment

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

I copied over the class types section, I don't know how to write .rst lol


TorchScript enum support is experimental..

Python enums can be used in TorchScript without any extra annotation or code:
Copy link
Contributor

@eellison eellison Sep 24, 2020

Choose a reason for hiding this comment

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

Personally I would cut down on this section a bit - it's pretty long for what is an easy & simple feature to use (enums). see how short the named tuple section is

Copy link
Author

Choose a reason for hiding this comment

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

What do you think I should cut out? Most of it is code samples.

Copy link
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

Meant to accept - these are just suggestions though, it looks good obviously feel free to keep whatever

Comment on lines 399 to 415

::

from enum import Enum

class IntEnum(Enum):
FOO = 1
BAR = 2

class FloatEnum(Enum):
FOO = 1.2
BAR = 2.3

class StringEnum(Enum):
FOO = "foo as in foo bar"
BAR = "bar as in foo bar"

Copy link
Contributor

Choose a reason for hiding this comment

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

Would cut out this part

Comment on lines 381 to 397

from enum import Enum

class Color(Enum):
RED = 1
GREEN = 2

@torch.jit.script
def return_enum(cond: bool):
if cond:
return Color.RED
else:
return Color.GREEN

self.assertEqual(return_enum(True), Color.RED)
self.assertEqual(return_enum(False), Color.GREEN)

Copy link
Contributor

Choose a reason for hiding this comment

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

And this part

Comment on lines 390 to 393
if cond:
return Color.RED
else:
return Color.GREEN
Copy link
Contributor

Choose a reason for hiding this comment

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

And then maybe include this example where you access the field name Color.RED or make it part of the other function

Meghan Lele added 3 commits September 24, 2020 12:34
**Summary**
This commit updates the TorchScript language reference to include
documentation on recently-added TorchScript enums. It also removed
`torch.no_grad` from the list of known unsupported `torch` modules and
classes because it is now supported.

**Test Plan**
Continuous integration.

[ghstack-poisoned]
**Summary**
This commit updates the TorchScript language reference to include
documentation on recently-added TorchScript enums. It also removed
`torch.no_grad` from the list of known unsupported `torch` modules and
classes because it is now supported.

**Test Plan**
Continuous integration.

[ghstack-poisoned]
**Summary**
This commit updates the TorchScript language reference to include
documentation on recently-added TorchScript enums. It also removed
`torch.no_grad` from the list of known unsupported `torch` modules and
classes because it is now supported.

**Test Plan**
Continuous integration.

[ghstack-poisoned]
@codecov
Copy link

codecov bot commented Sep 27, 2020

Codecov Report

Merging #45232 into gh/splitinfinity/49/base will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@                     Coverage Diff                      @@
##           gh/splitinfinity/49/base   #45232      +/-   ##
============================================================
- Coverage                     68.05%   68.05%   -0.01%     
============================================================
  Files                           396      396              
  Lines                         51235    51235              
============================================================
- Hits                          34868    34867       -1     
- Misses                        16367    16368       +1     
Impacted Files Coverage Δ
torch/testing/_internal/expecttest.py 77.55% <0.00%> (-1.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 36c3fbc...5b009a6. Read the comment docs.

Meghan Lele added 2 commits September 28, 2020 12:42
**Summary**
This commit updates the TorchScript language reference to include
documentation on recently-added TorchScript enums. It also removed
`torch.no_grad` from the list of known unsupported `torch` modules and
classes because it is now supported.

**Test Plan**
Continuous integration.

[ghstack-poisoned]
**Summary**
This commit updates the TorchScript language reference to include
documentation on recently-added TorchScript enums. It also removed
`torch.no_grad` from the list of known unsupported `torch` modules and
classes because it is now supported.

**Test Plan**
Continuous integration.

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

@SplitInfinity merged this pull request in 4af4b71.

@facebook-github-bot facebook-github-bot deleted the gh/splitinfinity/49/head branch October 2, 2020 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants