MCPcopy Create free account
hub / github.com/SooLab/CGFormer / _hook_rss_memory_pre_forward

Method _hook_rss_memory_pre_forward

bert/modeling_utils.py:86–95  ·  view source on GitHub ↗
(module, *args, **kwargs)

Source from the content-addressed store, hash-verified

84
85 @staticmethod
86 def _hook_rss_memory_pre_forward(module, *args, **kwargs):
87 try:
88 import psutil
89 except (ImportError):
90 raise ImportError("You need to install psutil (pip install psutil) to use memory tracing.")
91
92 process = psutil.Process(os.getpid())
93 mem = process.memory_info()
94 module.mem_rss_pre_forward = mem.rss
95 return None
96
97 @staticmethod
98 def _hook_rss_memory_post_forward(module, *args, **kwargs):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected