-
Notifications
You must be signed in to change notification settings - Fork 24.2k
[hop_schema] support gen_schema for invoke_subgraph #152984
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
base: gh/ydwu4/245/base
Are you sure you want to change the base?
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/152984
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit bb83b5c with merge base 7a0781e ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
def gen_schema(self, subgraph, identifier, *operands): | ||
from torch._higher_order_ops.schema import HopSchemaGenerator | ||
from torch._higher_order_ops.utils import ( | ||
check_input_alias_and_mutation_return_ouputs, | ||
) | ||
|
||
schema_gen = HopSchemaGenerator(self) | ||
schema_gen.add_arg("subgraph", subgraph) | ||
schema_gen.add_arg("identifier", identifier) | ||
example_inputs = [ | ||
n.meta["val"] if "val" in n.meta else n.meta["example_value"] | ||
for n in subgraph.graph.find_nodes(op="placeholder") | ||
] | ||
mutated_inputs, _, _, _, outputs = check_input_alias_and_mutation_return_ouputs( | ||
subgraph, example_inputs | ||
) | ||
for idx, arg in enumerate(operands): | ||
schema_gen.add_arg(f"arg{idx}", arg, is_mutated=idx in mutated_inputs) | ||
for out in outputs: | ||
schema_gen.add_output(out) | ||
|
||
return schema_gen.gen_schema() |
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.
not bad
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.
ofc, this is your design lol
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.
Honestly I don't remember this at all so it is now your design :P
Stack from ghstack (oldest at bottom):