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

Skip to content

Commit 1268629

Browse files
Remove warnings on non-buffer tensor constants
Pull Request resolved: #148483 cc @ezyang @SherlockNoMad @EikanWang @jgong5 @wenzhe-nrv @imported-using-ghimport Differential Revision: [D70577321](https://our.internmc.facebook.com/intern/diff/D70577321/) ghstack-source-id: 271094772
1 parent 2ee60ee commit 1268629

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
@@ -1748,8 +1748,6 @@ def check_arg(arg: Node, n: Optional[Node] = None) -> None:
17481748

17491749
# Check targets are legit
17501750
if self.owning_module:
1751-
num_warnings = 0
1752-
MAX_WARNINGS = 5
17531751
for node in self.nodes:
17541752
if node.op == "call_function":
17551753
if not callable(node.target):
@@ -1781,29 +1779,8 @@ def check_arg(arg: Node, n: Optional[Node] = None) -> None:
17811779
f"Node {node} target {node.target} {atom} of {seen_qualname} does "
17821780
"not reference an nn.Module"
17831781
)
1784-
elif (
1785-
node.op == "get_attr"
1786-
and not isinstance(new_m_itr, torch.nn.Module)
1787-
and not isinstance(new_m_itr, torch.nn.Parameter)
1788-
and atom not in m_itr._buffers
1789-
):
1790-
if num_warnings < MAX_WARNINGS:
1791-
# Don't emit this warning too frequently,
1792-
# for very large graphs this can become very expensive
1793-
# from a performance perspective.
1794-
warnings.warn(
1795-
f"Node {node} target {node.target} {atom} of {seen_qualname} does "
1796-
"not reference an nn.Module, nn.Parameter, or buffer, which is "
1797-
"what 'get_attr' Nodes typically target"
1798-
)
1799-
num_warnings += 1
1800-
else:
1801-
m_itr = new_m_itr
1802-
if num_warnings > MAX_WARNINGS:
1803-
warnings.warn(
1804-
f"Additional {num_warnings - MAX_WARNINGS} warnings "
1805-
"suppressed about get_attr references"
1806-
)
1782+
1783+
m_itr = new_m_itr
18071784

18081785
@compatibility(is_backward_compatible=True)
18091786
def eliminate_dead_code(

0 commit comments

Comments
 (0)
0