Skip to content
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

[fx] GraphModule copy top level attributes from root #45182

Closed
wants to merge 6 commits into from

Conversation

jerryzh168
Copy link
Contributor

@jerryzh168 jerryzh168 commented Sep 23, 2020

Stack from ghstack:

Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding __dict__

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: D23858632

Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding `__dict__`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding `__dict__`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
jerryzh168 added a commit that referenced this pull request Sep 23, 2020
Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding `__dict__`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: c9a0c7f570b44e99a83e46ccdc5e90139966ad70
Pull Request resolved: #45182
@dr-ci
Copy link

dr-ci bot commented Sep 23, 2020

💊 CI failures summary and remediations

As of commit cd94987 (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 16 times.

torch/fx/graph_module.py Outdated Show resolved Hide resolved
Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding `__dict__`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D23858632](https://our.internmc.facebook.com/intern/diff/D23858632)

[ghstack-poisoned]
jerryzh168 added a commit that referenced this pull request Sep 23, 2020
Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding `__dict__`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 3466ebdd4cafbca5ed305618307d6fb09b36fd89
Pull Request resolved: #45182
@codecov
Copy link

codecov bot commented Sep 23, 2020

Codecov Report

Merging #45182 into gh/jerryzh168/439/base will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@                   Coverage Diff                   @@
##           gh/jerryzh168/439/base   #45182   +/-   ##
=======================================================
  Coverage                   68.10%   68.11%           
=======================================================
  Files                         393      393           
  Lines                       50945    50953    +8     
=======================================================
+ Hits                        34698    34707    +9     
+ Misses                      16247    16246    -1     
Impacted Files Coverage Δ
torch/fx/graph_module.py 97.39% <100.00%> (+1.12%) ⬆️

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 c211a91...cd94987. Read the comment docs.

torch/fx/graph_module.py Outdated Show resolved Hide resolved
torch/fx/graph_module.py Outdated Show resolved Hide resolved
Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding `__dict__`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D23858632](https://our.internmc.facebook.com/intern/diff/D23858632)

[ghstack-poisoned]
torch/fx/graph_module.py Outdated Show resolved Hide resolved
torch/fx/graph_module.py Outdated Show resolved Hide resolved
Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding `__dict__`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D23858632](https://our.internmc.facebook.com/intern/diff/D23858632)

[ghstack-poisoned]
Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding `__dict__`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D23858632](https://our.internmc.facebook.com/intern/diff/D23858632)

[ghstack-poisoned]
jerryzh168 added a commit that referenced this pull request Sep 24, 2020
Summary:
Previously only the attributes that's used in the graph is copied in the constructor
of GraphModule, this PR adds the support for copying all attributes by overriding `__dict__`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: df0b0b99545320553100d787c4b81f053565b291
Pull Request resolved: #45182
return GraphModule(fake_mod, self.graph)
graph_module = GraphModule(fake_mod, self.graph)
# skip overwriting generated attributes
for attr in ['code', '_graph', '_modules']:
Copy link
Contributor

Choose a reason for hiding this comment

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

These fields are not complete. For instance _parameters and _buffers are not included and copying them might break the nn.Module similar to _modules. Any attempt to list parameters here would be very fragile because changes to nn.Module would affect what this list needs to be with no reliable way to inform an editor of nn.Module that this list also needs to be modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually I'm not sure why I included _modules we probably don't need that. This is just for skipping attributes generated when creating a GraphModule.

@jerryzh168
Copy link
Contributor Author

fixed in the original PR: #44074

@jerryzh168 jerryzh168 closed this Oct 1, 2020
@facebook-github-bot facebook-github-bot deleted the gh/jerryzh168/439/head branch November 1, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants