(self, *args, **kwargs)
| 73 | return float('inf') |
| 74 | |
| 75 | def run(self, *args, **kwargs): |
| 76 | self.nargs = dict(zip(self.arg_names, args)) |
| 77 | if len(self.configs) > 1: |
| 78 | key = tuple(args[i] for i in self.key_idx) |
| 79 | |
| 80 | # This reduces the amount of autotuning by rounding the keys to the nearest power of two |
| 81 | # In my testing this gives decent results, and greatly reduces the amount of tuning required |
| 82 | if self.nearest_power_of_two: |
| 83 | key = tuple([2 ** int(math.log2(x) + 0.5) for x in key]) |
| 84 | |
| 85 | if key not in self.cache: |
| 86 | # prune configs |
| 87 | pruned_configs = self.prune_configs(kwargs) |
| 88 | bench_start = time.time() |
| 89 | timings = {config: self._bench(*args, config=config, **kwargs) |
| 90 | for config in pruned_configs} |
| 91 | bench_end = time.time() |
| 92 | self.bench_time = bench_end - bench_start |
| 93 | self.cache[key] = builtins.min(timings, key=timings.get) |
| 94 | self.hook(args) |
| 95 | self.configs_timings = timings |
| 96 | config = self.cache[key] |
| 97 | else: |
| 98 | config = self.configs[0] |
| 99 | self.best_config = config |
| 100 | if config.pre_hook is not None: |
| 101 | config.pre_hook(self.nargs) |
| 102 | return self.fn.run(*args, num_warps=config.num_warps, num_stages=config.num_stages, **kwargs, **config.kwargs) |
| 103 | |
| 104 | def prune_configs(self, kwargs): |
| 105 | pruned_configs = self.configs |
no test coverage detected