Support with_stack and record_shapes in profiler (#4740)
Co-authored-by: Lianmin Zheng <lianminzheng@gmail.com>
This commit is contained in:
@@ -675,6 +675,8 @@ class ProfileReq:
|
|||||||
output_dir: Optional[str] = None
|
output_dir: Optional[str] = None
|
||||||
num_steps: Optional[int] = None
|
num_steps: Optional[int] = None
|
||||||
activities: Optional[List[str]] = None
|
activities: Optional[List[str]] = None
|
||||||
|
with_stack: Optional[bool] = None
|
||||||
|
record_shapes: Optional[bool] = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -1807,7 +1807,11 @@ class Scheduler(
|
|||||||
def profile(self, recv_req: ProfileReq):
|
def profile(self, recv_req: ProfileReq):
|
||||||
if recv_req.type == ProfileReqType.START_PROFILE:
|
if recv_req.type == ProfileReqType.START_PROFILE:
|
||||||
return self.start_profile(
|
return self.start_profile(
|
||||||
recv_req.output_dir, recv_req.num_steps, recv_req.activities
|
recv_req.output_dir,
|
||||||
|
recv_req.num_steps,
|
||||||
|
recv_req.activities,
|
||||||
|
recv_req.with_stack,
|
||||||
|
recv_req.record_shapes,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return self.stop_profile()
|
return self.stop_profile()
|
||||||
@@ -1817,6 +1821,8 @@ class Scheduler(
|
|||||||
output_dir: Optional[str],
|
output_dir: Optional[str],
|
||||||
num_steps: Optional[int],
|
num_steps: Optional[int],
|
||||||
activities: Optional[List[str]],
|
activities: Optional[List[str]],
|
||||||
|
with_stack: Optional[bool],
|
||||||
|
record_shapes: Optional[bool],
|
||||||
) -> None:
|
) -> None:
|
||||||
if self.profiler_activities:
|
if self.profiler_activities:
|
||||||
return ProfileReqOutput(
|
return ProfileReqOutput(
|
||||||
@@ -1847,7 +1853,8 @@ class Scheduler(
|
|||||||
if torchprof_activities:
|
if torchprof_activities:
|
||||||
self.torch_profiler = torch.profiler.profile(
|
self.torch_profiler = torch.profiler.profile(
|
||||||
activities=torchprof_activities,
|
activities=torchprof_activities,
|
||||||
with_stack=True,
|
with_stack=with_stack if with_stack is not None else True,
|
||||||
|
record_shapes=record_shapes if record_shapes is not None else False,
|
||||||
)
|
)
|
||||||
self.torch_profiler.start()
|
self.torch_profiler.start()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user