|
23 | 23 |
|
24 | 24 | from ...contrib.popen_pool import PopenPoolExecutor |
25 | 25 | from ...runtime import Device, Module |
| 26 | +from ..profiler import Profiler |
26 | 27 | from ..utils import derived_object, get_global_func_with_default_on_worker |
27 | 28 | from .config import EvaluatorConfig |
28 | | -from .runner import PyRunner, RunnerFuture, RunnerInput, RunnerResult, PyRunnerFuture |
| 29 | +from .runner import PyRunner, PyRunnerFuture, RunnerFuture, RunnerInput, RunnerResult |
29 | 30 | from .utils import ( |
30 | | - T_ARGUMENT_LIST, |
31 | 31 | T_ARG_INFO_JSON_OBJ_LIST, |
| 32 | + T_ARGUMENT_LIST, |
32 | 33 | alloc_argument_common, |
33 | 34 | run_evaluator_common, |
34 | 35 | ) |
35 | 36 |
|
36 | | - |
37 | 37 | logger = logging.getLogger(__name__) # pylint: disable=invalid-name |
38 | 38 |
|
39 | 39 |
|
@@ -137,26 +137,29 @@ def resource_handler(): |
137 | 137 | yield |
138 | 138 | finally: |
139 | 139 | # Final step. Always clean up |
140 | | - f_cleanup() |
| 140 | + with Profiler.timeit("LocalRunner/cleanup"): |
| 141 | + f_cleanup() |
141 | 142 |
|
142 | 143 | with resource_handler(): |
143 | 144 | # Step 1: create the local runtime module |
144 | | - rt_mod = tvm.runtime.load_module(artifact_path) |
145 | | - # Step 2: create the local device |
146 | | - device = tvm.runtime.device(dev_type=device_type, dev_id=0) |
147 | | - # Step 3: Allocate input arguments |
148 | | - repeated_args: List[T_ARGUMENT_LIST] = f_alloc_argument( |
149 | | - device, |
150 | | - args_info, |
151 | | - alloc_repeat, |
152 | | - ) |
153 | | - # Step 4: Run time_evaluator |
154 | | - costs: List[float] = f_run_evaluator( |
155 | | - rt_mod, |
156 | | - device, |
157 | | - evaluator_config, |
158 | | - repeated_args, |
159 | | - ) |
| 145 | + with Profiler.timeit("LocalRunner/load_module"): |
| 146 | + rt_mod = tvm.runtime.load_module(artifact_path) |
| 147 | + # Step 2: Allocate input arguments |
| 148 | + with Profiler.timeit("LocalRunner/alloc_argument"): |
| 149 | + device = tvm.runtime.device(dev_type=device_type, dev_id=0) |
| 150 | + repeated_args: List[T_ARGUMENT_LIST] = f_alloc_argument( |
| 151 | + device, |
| 152 | + args_info, |
| 153 | + alloc_repeat, |
| 154 | + ) |
| 155 | + # Step 3: Run time_evaluator |
| 156 | + with Profiler.timeit("LocalRunner/run_evaluator"): |
| 157 | + costs: List[float] = f_run_evaluator( |
| 158 | + rt_mod, |
| 159 | + device, |
| 160 | + evaluator_config, |
| 161 | + repeated_args, |
| 162 | + ) |
160 | 163 | return costs |
161 | 164 |
|
162 | 165 |
|
@@ -313,9 +316,6 @@ def _check( |
313 | 316 | get_global_func_with_default_on_worker(name=f_alloc_argument, default=None) |
314 | 317 | get_global_func_with_default_on_worker(name=f_run_evaluator, default=None) |
315 | 318 | get_global_func_with_default_on_worker(name=f_cleanup, default=None) |
316 | | - get_global_func_with_default_on_worker( |
317 | | - name="tvm.contrib.random.random_fill", default=None |
318 | | - ) |
319 | 319 |
|
320 | 320 | value = self.pool.submit( |
321 | 321 | _check, |
@@ -348,7 +348,7 @@ def default_alloc_argument( |
348 | 348 | The allocation args |
349 | 349 | """ |
350 | 350 | f_random_fill = get_global_func_with_default_on_worker( |
351 | | - name="tvm.contrib.random.random_fill", default=None |
| 351 | + name="tvm.contrib.random.random_fill_for_measure", default=None |
352 | 352 | ) |
353 | 353 | return alloc_argument_common(f_random_fill, device, args_info, alloc_repeat) |
354 | 354 |
|
|
0 commit comments