Skip to content

Commit 2d8fb87

Browse files
[Executorch][Export][3/N] Add timing information to all the stages for debugging
Pull Request resolved: #16128 Add timing instrumentation to all export pipeline stages helps with identifying the long running stages. ghstack-source-id: 327669271 @exported-using-ghexport Differential Revision: [D87576724](https://our.internmc.facebook.com/intern/diff/D87576724/)
1 parent f1fbd45 commit 2d8fb87

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

export/export.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# LICENSE file in the root directory of this source tree.
77

88
import logging
9+
import time
910
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
1011

1112
import torch
@@ -441,8 +442,13 @@ def _run_pipeline(self) -> None:
441442

442443
logging.info(f"Executing stage: {stage_type}")
443444

445+
start = time.perf_counter()
444446
stage.run(current_artifact)
447+
elapsed = (time.perf_counter() - start) * 1000
445448
current_artifact = stage.get_artifacts()
449+
current_artifact.add_context("duration_ms", int(elapsed))
450+
451+
logging.info(f"Stage {stage_type} execution done")
446452

447453
self._stage_to_artifacts[stage_type] = current_artifact
448454

0 commit comments

Comments
 (0)