Serialize timing cache of given builder config to file specified by out_path return True if the cache is successfully serialized, False otherwise
(builder_config: BuilderConfig, out_path: str)
| 426 | |
| 427 | @staticmethod |
| 428 | def save_timing_cache(builder_config: BuilderConfig, out_path: str) -> bool: |
| 429 | '''Serialize timing cache of given builder config to file specified by out_path |
| 430 | return True if the cache is successfully serialized, False otherwise |
| 431 | ''' |
| 432 | cache = builder_config.trt_builder_config.get_timing_cache() |
| 433 | if cache is None: |
| 434 | logger.warning( |
| 435 | 'No timing cache found in the given builder config, skip saving.' |
| 436 | ) |
| 437 | return False |
| 438 | with cache.serialize() as buffer: |
| 439 | with open(out_path, "wb") as f: |
| 440 | f.write(buffer) |
| 441 | f.flush() |
| 442 | os.fsync(f) |
| 443 | logger.info(f'Timing cache serialized to {out_path}') |
| 444 | return True |
| 445 | |
| 446 | @staticmethod |
| 447 | def save_config(builder_config: BuilderConfig, config_path: str): |