8000 Suppress more warnings · pytorch/pytorch@fbd1ded · GitHub
[go: up one dir, main page]

Skip to content

Commit fbd1ded

Browse files
Suppress more warnings
ghstack-source-id: 7a8cf6c Pull Request resolved: #148488
1 parent 73b4391 commit fbd1ded

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

torch/_export/passes/lift_constants_pass.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# mypy: allow-untyped-defs
22
import collections
3+
import logging
34
import warnings
45
from typing import Any, Union
56

@@ -18,6 +19,8 @@
1819
)
1920
from torch.fx.graph_module import _get_attr
2021

22+
log = logging.getLogger(__name__)
23+
2124

2225
class ConstantAttrMap(collections.abc.MutableMapping):
2326
"""A mapping class that understands how to use module constants (tensors,
@@ -198,7 +201,7 @@ def lift_constants_pass(
198201
elif isinstance(constant_val, torch.Tensor):
199202
# Remove the parameterness of constant_val
200203
if isinstance(constant_val, torch.nn.Parameter):
201-
warnings.warn(
204+
log.debug(
202205
f"{node.target} created when tracing {node.meta.get('stack_trace', '<unknown stack>')} is a parameter. But"
203206
f"it's not registered with register_parameter(). export will treat it as a constant tensor"
204207
)

torch/export/_unlift.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ def _unlift_inputs_as_getattr(
7878

7979
else:
8080
with gm.graph.inserting_after(input_node):
81-
getattr_node = gm.graph.get_attr(lifted_node)
81+
# It is fine to ignore this warning because
82+
# it is guaranteed that we will populate this
83+
# attr later.
84+
with warnings.catch_warnings():
85+
warnings.simplefilter("ignore")
86+
getattr_node = gm.graph.get_attr(lifted_node)
8287
input_node.replace_all_uses_with(getattr_node)
8388
metadata = input_node.meta
8489
gm.graph.erase_node(input_node)

torch/fx/experimental/proxy_tensor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import traceback
1515
import typing
1616
import typing_extensions
17-
import warnings
1817
import weakref
1918
from collections import defaultdict
2019
from collections.abc import Generator, Mapping, Sequence
@@ -1799,7 +1798,7 @@ def call_module(
17991798
try:
18001799
return Tracer.call_module(self, m, forward, args, kwargs)
18011800
except _ModuleNotInstalledAsSubmoduleError:
1802-
warnings.warn(
1801+
log.debug(
18031802
f"Unable to find the path of the module {m}. "
18041803
"This might be because the module was not properly registered "
18051804
"as a submodule, which is not good practice. We will trace "

0 commit comments

Comments
 (0)
0