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

Skip to content

Commit dbd7db7

Browse files
Suppress more warnings
ghstack-source-id: 8f58615 Pull Request resolved: #148488
1 parent fe08d1f commit dbd7db7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

torch/_export/passes/lift_constants_pass.py

+4-1
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

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ 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+
with warnings.catch_warnings():
82+
warnings.simplefilter("ignore")
83+
getattr_node = gm.graph.get_attr(lifted_node)
8284
input_node.replace_all_uses_with(getattr_node)
8385
metadata = input_node.meta
8486
gm.graph.erase_node(input_node)

0 commit comments

Comments
 (0)
0