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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TorchScript] Support user defined classes as constants #45556
Conversation
This pull request was exported from Phabricator. Differential Revision: D23994974 |
💊 CI failures summary and remediationsAs of commit b71b970 (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. This comment has been revised 111 times. |
This pull request was exported from Phabricator. Differential Revision: D23994974 |
675c6b7
to
8aa16c8
Compare
@@ -459,6 +459,9 @@ std::ostream& IValue::repr( | |||
return out << enum_holder->qualifiedClassName() << "." << | |||
enum_holder->name(); | |||
} | |||
case IValue::Tag::Object: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be TORCH_CHECK? we don't expect to handle this case in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should merge this if it's going to silently break the ability of a user to save and load their model in combination with torch.jit.freeze.
However, I think it would be very easy to add serialization support in combination with #37631, which is accepted but not merged.
This pull request was exported from Phabricator. Differential Revision: D23994974 |
8aa16c8
to
8308384
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where the tests?
This pull request was exported from Phabricator. Differential Revision: D23994974 |
8308384
to
b3f5275
Compare
@@ -864,6 +864,7 @@ struct PythonPrintImpl { | |||
|
|||
void printConstant(TaggedStringStream& stmt, const IValue& v) { | |||
const auto customFormatter = [&](std::ostream& ss, const IValue& v) { | |||
// TODO Add support for serialization of custom classes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be an assertion here?
To make sure serialization is not invoked where there is a custom class as a constant
This pull request was exported from Phabricator. Differential Revision: D23994974 |
b3f5275
to
12a4c40
Compare
Summary: Pull Request resolved: pytorch#45556 User defined classes can be used as constants. This is useful when freezing and removing the module from the graph. Test Plan: waitforsadcastle Differential Revision: D23994974 fbshipit-source-id: 0bf853cf20b92c5621db92088f758b5789446a3c
This pull request was exported from Phabricator. Differential Revision: D23994974 |
12a4c40
to
c723d35
Compare
This pull request was exported from Phabricator. Differential Revision: D23994974 |
c723d35
to
7b647b0
Compare
This pull request was exported from Phabricator. Differential Revision: D23994974 |
7b647b0
to
a026670
Compare
13f168d
to
9e596c5
Compare
This pull request was exported from Phabricator. Differential Revision: D23994974 |
This pull request was exported from Phabricator. Differential Revision: D23994974 |
9e596c5
to
9ffbf9d
Compare
Thanks @bwasti if this is enabled by default, you can also remove https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/passes/quantization/finalize.cpp#L99 and see if anything breaks (the pass is added specifically to fold constant objects) |
This pull request was exported from Phabricator. Differential Revision: D23994974 |
9ffbf9d
to
88573c7
Compare
88573c7
to
1c82cad
Compare
This pull request was exported from Phabricator. Differential Revision: D23994974 |
1c82cad
to
5c81b29
Compare
This pull request was exported from Phabricator. Differential Revision: D23994974 |
This pull request was exported from Phabricator. Differential Revision: D23994974 |
5c81b29
to
815a4dd
Compare
Summary: Pull Request resolved: pytorch/pytorch#45556 User defined classes can be used as constants. This is useful when freezing and removing the module from the graph. Differential Revision: D23994974 fbshipit-source-id: c7683c44ae9288db56444e32181583bc89d9ed93
Summary: Pull Request resolved: pytorch/glow#5062 Pull Request resolved: pytorch#45556 User defined classes can be used as constants. This is useful when freezing and removing the module from the graph. Test Plan: waitforsadcastle Reviewed By: eellison Differential Revision: D23994974 fbshipit-source-id: 6c494269e222b7e1b5ecddf0c460ae8c09ac0556
This pull request was exported from Phabricator. Differential Revision: D23994974 |
815a4dd
to
b71b970
Compare
Codecov Report
@@ Coverage Diff @@
## master #45556 +/- ##
==========================================
- Coverage 81.33% 81.30% -0.03%
==========================================
Files 1839 1839
Lines 198589 198645 +56
==========================================
- Hits 161527 161518 -9
- Misses 37062 37127 +65 |
This pull request has been merged in 43a9d6f. |
Summary: User defined classes can be used as constants. This is useful when freezing and removing the module from the graph.
Test Plan: waitforsadcastle
Differential Revision: D23994974