MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / __init__

Method __init__

imperative/python/megengine/utils/profiler.py:71–104  ·  view source on GitHub ↗
(
        self,
        path: str = "profile",
        format: str = "chrome_timeline.json",
        formats: List[str] = None,
        with_backtrace: bool = False,
        with_scopes: bool = False,
        **kwargs
    )

Source from the content-addressed store, hash-verified

69 valid_formats = {"chrome_timeline.json", "memory_flow.svg"}
70
71 def __init__(
72 self,
73 path: str = "profile",
74 format: str = "chrome_timeline.json",
75 formats: List[str] = None,
76 with_backtrace: bool = False,
77 with_scopes: bool = False,
78 **kwargs
79 ) -> None:
80 if not formats:
81 formats = [format]
82
83 assert not isinstance(formats, str), "formats excepts list, got str"
84
85 for format in formats:
86 assert format in Profiler.valid_formats, "unsupported format {}".format(
87 format
88 )
89
90 self._path = path
91 self._formats = formats
92 self._options = {}
93 for opt, optval in Profiler.valid_options.items():
94 self._options[opt] = int(kwargs.pop(opt, optval))
95 self._pid = "<PID>"
96 self._dump_callback = None
97 self._api_patcher = None
98 self._with_scopes = with_scopes
99 if self._options.get("enable_cupti", 0):
100 if cupti_available():
101 enable_cupti()
102 else:
103 get_logger().warning("CuPTI unavailable")
104 self.with_backtrace = with_backtrace
105
106 @property
107 def path(self):

Callers

nothing calls this directly

Calls 4

get_loggerFunction · 0.85
itemsMethod · 0.80
formatMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected