mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
[Dynamo] Add debug linting option for graph dedupe (#150053)
As title Pull Request resolved: https://github.com/pytorch/pytorch/pull/150053 Approved by: https://github.com/StrongerXi, https://github.com/anijain2305
This commit is contained in:
parent
25309a17f0
commit
d2c0c65ea1
|
|
@ -432,6 +432,10 @@ use_graph_deduplication = False
|
||||||
# This flag is ignored if use_graph_deduplication is True
|
# This flag is ignored if use_graph_deduplication is True
|
||||||
track_nodes_for_deduplication = False
|
track_nodes_for_deduplication = False
|
||||||
|
|
||||||
|
# Whether to lint the graph after each region is replaced
|
||||||
|
# (Debug)
|
||||||
|
graph_deduplication_lint = False
|
||||||
|
|
||||||
# Issues a warning in Python 3.13.0 for possibly slower guard evaluation and
|
# Issues a warning in Python 3.13.0 for possibly slower guard evaluation and
|
||||||
# instructs user to attempt using 3.13.1+, where the CPython bug is fixed.
|
# instructs user to attempt using 3.13.1+, where the CPython bug is fixed.
|
||||||
# Should be disabled in dynamo-wrapped tests since some tests check that no warnings are issued.
|
# Should be disabled in dynamo-wrapped tests since some tests check that no warnings are issued.
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ from collections.abc import Iterable
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import torch.fx
|
import torch.fx
|
||||||
|
from torch._dynamo import config
|
||||||
from torch._higher_order_ops.utils import has_potential_input_alias_or_mutation
|
from torch._higher_order_ops.utils import has_potential_input_alias_or_mutation
|
||||||
from torch.utils._pytree import tree_flatten
|
from torch.utils._pytree import tree_flatten
|
||||||
|
|
||||||
|
|
@ -154,6 +155,9 @@ def _replace_region_with_subgraph(
|
||||||
for node in reversed(region):
|
for node in reversed(region):
|
||||||
graph.erase_node(node)
|
graph.erase_node(node)
|
||||||
|
|
||||||
|
if config.graph_deduplication_lint:
|
||||||
|
graph.lint()
|
||||||
|
|
||||||
|
|
||||||
def _get_external_inputs(
|
def _get_external_inputs(
|
||||||
region: Region,
|
region: Region,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user