pytorch/pytorch

Logging when executing fx.Interpreter

クローズ

#117,351 opened on 2024/01/12

 (12 件のコメント) (0 件のリアクション) (0 人の担当者)Python (28,884 件のフォーク)batch import
good first issuemodule: loggingoncall: pt2triaged

Repository metrics

Stars
 (102,440 個のスター)
PR merge metrics
 (平均マージ 1d 10h) (30d で 42 merged PRs)

説明

🐛 Describe the bug

Something like this:

diff --git a/torch/fx/interpreter.py b/torch/fx/interpreter.py
index c36c5c1004b..afc963ed545 100644
--- a/torch/fx/interpreter.py
+++ b/torch/fx/interpreter.py
@@ -7,10 +7,14 @@ from ._compatibility import compatibility
 from . import config
 import torch.fx.traceback as fx_traceback
 import torch
+from torch._logging import LazyString
 from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
 import inspect
 from contextlib import contextmanager
 from torch.hub import tqdm
+import logging
+
+log = logging.getLogger(__name__)
 
 __all__ = ['Interpreter', 'Transformer']
 
@@ -194,6 +198,7 @@ class Interpreter:
         Returns:
             Any: The result of executing ``n``
         """
+        log.debug("run_node %s", LazyString(lambda: n.format_node()))
         with self._set_current_node(n):
             args, kwargs = self.fetch_args_kwargs_from_env(n)
             assert isinstance(args, tuple)

Versions

main

cc @msaroufim @wconstab @bdhirsh @anijain2305 @zou3519

コントリビューターガイド