-
Notifications
You must be signed in to change notification settings - Fork 25.3k
[fx] Replace literals with placeholder helper #97683
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/97683
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 0119bdf: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
test/fx/test_matcher_utils.py
Outdated
|
||
def test_subgraph_matcher_ignore_literals(self): | ||
def original(x): | ||
return torch.nn.Linear(3, 3).eval()(x) |
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.
nit... This is a kinda unconventional way to construct graphs with different literals... :)
You are relying on the underlying weight_initializer's behavior (torch.ops.aten.uniform_) to set different literals.
I would construct something more explicit, e.g. y = x + 1
vs. y = x + 2
graph():
%x_1 : [#users=1] = placeholder[target=x_1]
%_param_constant0 : [#users=1] = get_attr[target=_param_constant0]
%uniform_ : [#users=1] = call_function[target=torch.ops.aten.uniform_.default](args = (%_param_constant0, -0.5773502691896257, 0.5773502691896257), kwargs = {})
%_param_constant1 : [#users=1] = get_attr[target=_param_constant1]
%uniform__1 : [#users=1] = call_function[target=torch.ops.aten.uniform_.default](args = (%_param_constant1, -0.5773502691896258, 0.5773502691896258), kwargs = {})
%t : [#users=1] = call_function[target=torch.ops.aten.t.default](args = (%uniform_,), kwargs = {})
%addmm : [#users=1] = call_function[target=torch.ops.aten.addmm.default](args = (%uniform__1, %x_1, %t), kwargs = {})
return addmm
Helper function to replace literals that show up in call_function nodes in the graph to become placeholders so that they can be represented as wildcards when matching with the SubgraphMatcher. This pass causes the resulting graph to not be runnable with the original inputs since adding placeholders to the graph will change the number of inputs needed for the graph. Test: `python test/test_fx.py TestMatcher`
e4270c2
to
0119bdf
Compare
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Helper function to replace literals that show up in call_function nodes in the graph to become placeholders so that they can be represented as wildcards when matching with the SubgraphMatcher. This pass causes the resulting graph to not be runnable with the original inputs since adding placeholders to the graph will change the number of inputs needed for the graph.
Test:
python test/test_fx.py TestMatcher
Fixes #ISSUE_NUMBER