Get an evaluator that measures time cost of running function. Parameters ---------- func_name: str The name of the function in the module. dev: Device The device we should run this function on. number: int The number of t
(
self,
func_name,
dev,
number=10,
repeat=1,
min_repeat_ms=0,
limit_zero_time_iterations=100,
cooldown_interval_ms=0,
repeats_to_cooldown=1,
cache_flush_bytes=0,
f_preproc="",
)
| 323 | return fcompile(file_name, files, **kwargs) |
| 324 | |
| 325 | def time_evaluator( |
| 326 | self, |
| 327 | func_name, |
| 328 | dev, |
| 329 | number=10, |
| 330 | repeat=1, |
| 331 | min_repeat_ms=0, |
| 332 | limit_zero_time_iterations=100, |
| 333 | cooldown_interval_ms=0, |
| 334 | repeats_to_cooldown=1, |
| 335 | cache_flush_bytes=0, |
| 336 | f_preproc="", |
| 337 | ): |
| 338 | """Get an evaluator that measures time cost of running function. |
| 339 | |
| 340 | Parameters |
| 341 | ---------- |
| 342 | func_name: str |
| 343 | The name of the function in the module. |
| 344 | |
| 345 | dev: Device |
| 346 | The device we should run this function on. |
| 347 | |
| 348 | number: int |
| 349 | The number of times to run this function for taking average. |
| 350 | We call these runs as one `repeat` of measurement. |
| 351 | |
| 352 | repeat: int, optional |
| 353 | The number of times to repeat the measurement. |
| 354 | In total, the function will be invoked (1 + number x repeat) times, |
| 355 | where the first one is warm up and will be discarded. |
| 356 | The returned result contains `repeat` costs, |
| 357 | each of which is an average of `number` costs. |
| 358 | |
| 359 | min_repeat_ms: int, optional |
| 360 | The minimum duration of one `repeat` in milliseconds. |
| 361 | By default, one `repeat` contains `number` runs. If this parameter is set, |
| 362 | the parameters `number` will be dynamically adjusted to meet the |
| 363 | minimum duration requirement of one `repeat`. |
| 364 | i.e., When the run time of one `repeat` falls below this time, the `number` parameter |
| 365 | will be automatically increased. |
| 366 | |
| 367 | limit_zero_time_iterations: int, optional |
| 368 | The maximum number of repeats when measured time is equal to 0. |
| 369 | It helps to avoid hanging during measurements. |
| 370 | |
| 371 | cooldown_interval_ms: int, optional |
| 372 | The cooldown interval in milliseconds between the number of repeats defined by |
| 373 | `repeats_to_cooldown`. |
| 374 | |
| 375 | repeats_to_cooldown: int, optional |
| 376 | The number of repeats before the cooldown is activated. |
| 377 | |
| 378 | cache_flush_bytes: int, optional |
| 379 | The number of bytes to flush from the cache before each repeat. |
| 380 | |
| 381 | f_preproc: str, optional |
| 382 | The preprocess function name we want to execute before executing the time evaluator. |
no outgoing calls