Skip to content

Conversation

angelayi
Copy link
Contributor

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

@angelayi angelayi requested a review from SherlockNoMad March 27, 2023 17:16
@pytorch-bot pytorch-bot bot added the release notes: fx release notes category label Mar 27, 2023
@pytorch-bot
Copy link

pytorch-bot bot commented Mar 27, 2023

🔗 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 Failures

As of commit 0119bdf:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@angelayi angelayi requested a review from SherlockNoMad March 28, 2023 20:08

def test_subgraph_matcher_ignore_literals(self):
def original(x):
return torch.nn.Linear(3, 3).eval()(x)
Copy link
Contributor

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`
@angelayi
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 29, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@angelayi
Copy link
Contributor Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@github-actions github-actions bot deleted the replace_literals branch September 28, 2024 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: fx release notes category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants