8000 Remove warnings on non-buffer tensor constants (#148483) · pytorch/pytorch@fb0e9cb · GitHub
[go: up one dir, main page]

Skip to content

Commit fb0e9cb

Browse files
tugsbayasgalanpytorchmergebot
authored andcommitted
Remove warnings on non-buffer tensor constants (#148483)
Export already registers tensor constants directly in the graph and this is also true for Torchbind objects. This removes warning that pollutes the output. Differential Revision: [D70577856](https://our.internmc.facebook.com/intern/diff/D70577856) Pull Request resolved: #148483 Approved by: https://github.com/zhxchen17, https://github.com/zou3519 ghstack dependencies: #148364
1 parent 29fd875 commit fb0e9cb

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

torch/fx/graph.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,8 +1726,6 @@ def check_arg(arg: Node, n: Optional[Node] = None) -> None:
17261726

17271727
# Check targets are legit
17281728
if self.owning_module:
1729-
num_warnings = 0
1730-
MAX_WARNINGS = 5
17311729
for node in self.nodes:
17321730
if node.op == "call_function":
17331731
if not callable(node.target):
@@ -1759,29 +1757,8 @@ def check_arg(arg: Node, n: Optional[Node] = None) -> None:
17591757
f"Node {node} target {node.target} {atom} of {seen_qualname} does "
17601758
"not reference an nn.Module"
17611759
)
1762-
elif (
1763-
node.op == "get_attr"
1764-
and not isinstance(new_m_itr, torch.nn.Module)
1765-
and not isinstance(new_m_itr, torch.nn.Parameter)
1766-
and atom not in m_itr._buffers
1767-
):
1768-
if num_warnings < MAX_WARNINGS:
1769-
# Don't emit this warning too frequently,
1770-
# for very large graphs this can become very expensive
1771-
# from a performance perspective.
1772-
warnings.warn(
1773-
f"Node {node} target {node.target} {atom} of {seen_qualname} does "
1774-
"not reference an nn.Module, nn.Parameter, or buffer, which is "
1775-
"what 'get_attr' Nodes typically target"
1776-
)
1777-
num_warnings += 1
1778-
else:
1779-
m_itr = new_m_itr
1780-
if num_warnings > MAX_WARNINGS:
1781-
warnings.warn(
1782-
f"Additional {num_warnings - MAX_WARNINGS} warnings "
1783-
"suppressed about get_attr references"
1784-
)
1760+
1761+
m_itr = new_m_itr
17851762

17861763
@compatibility(is_backward_compatible=True)
17871764
def eliminate_dead_code(

0 commit comments

Comments
 (0)
0