1515# limitations under the License.
1616#
1717
18- import inspect
19- from dataclasses import dataclass
2018from textwrap import indent
2119from typing import Any , List , Optional , Tuple
2220
@@ -84,12 +82,14 @@ def apply_color(inp, color):
8482 return frame_info
8583
8684
87- def str_from_stack_info (stack_info : "utils.stack_info.StackInfo" , enable_color : bool = True ) -> Optional [str ]:
85+ def str_from_stack_info (
86+ stack_info : "utils.stack_info.StackInfo" , enable_color : bool = True , fetch_source_code : bool = True
87+ ) -> Optional [str ]:
8888 from nvtripy .frontend .module import module
8989
9090 def should_exclude (source_info ):
9191 return (
92- source_info .code is None
92+ ( fetch_source_code and source_info .code is None )
9393 or source_info .module in utils .stack_info .get_module_names_to_exclude_from_stack_info ()
9494 # Exclude module.__call__ since it just invokes forward and clutters the stack trace
9595 or (source_info .module == module .__name__ and source_info .function == "__call__" )
@@ -98,7 +98,8 @@ def should_exclude(source_info):
9898 frame_strs = []
9999 num_frames_printed = 0
100100
101- stack_info .fetch_source_code ()
101+ if fetch_source_code :
102+ stack_info .fetch_source_code ()
102103 for index , source_info in enumerate (stack_info ):
103104 if should_exclude (source_info ):
104105 continue
0 commit comments