docstr: :param prune_configs_by: a dict of functions that are used to prune configs, fields:
      'perf_model': performance model used to predicate running time with different configs, returns running time
      'top_k': number of configs to bench
      'prune_num_stages_by'(optional): a function used to prune num_stages. It takes configs:List[Config] as its input, and returns pruned configs.
docstr_tok: [":","param","prune_configs_by",":","a","dict","of","functions","that","are","used","to","prune","configs",",","fields",":","'perf_model","'",":","performance","model","used","to","predicate","running","time","with","different","configs",",","returns","running","time","'top_k","'",":","number","of","configs","to","bench","'prune_num_stages_by","'","(","optional",")",":","a","function","used","to","prune","num_stages",".","It","takes","configs",":","List","[","Config","]","as","its","input",",","and","returns","pruned","configs","."]
code: def __init__(
      self,
      fn,
      arg_names,
      configs,
      key,
      reset_to_zero,
      restore_value,
      prune_configs_by: Dict = None,
      warmup=25,
      rep=100,
  ):
      """
      :param prune_configs_by: a dict of functions that are used to prune configs, fields:
          'perf_model': performance model used to predicate running time with different configs, returns running time
          'top_k': number of configs to bench
          'prune_num_stages_by'(optional): a function used to prune num_stages. It takes configs:List[Config] as its input, and returns pruned configs.
      """
      if not configs:
          self.configs = [
              Config({}, num_warps=4, num_stages=2, num_ctas=1)
          ]
      else:
          self.configs = configs
      self.key_idx = [arg_names.index(k) for k in key]
      self.cache = {}
      self.arg_names = arg_names
  
      # Reset to zero or restore values
      self.reset_idx = []
      if reset_to_zero is not None:
          self.reset_idx = [arg_names.index(k) for k in reset_to_zero]
      self.restore_idx = []
      if restore_value is not None:
          self.restore_idx = [arg_names.index(k) for k in restore_value]
  
      # Hook to reset or restore for required tensors
      self.pre_hook = lambda args, reset_only=False: 0
      self.post_hook = lambda args: 0
      if len(self.reset_idx) > 0 or len(self.restore_idx) > 0:
  
          def _pre_hook(args, reset_only=False):
              for i in self.reset_idx:
                  args[i].zero_()
              if not reset_only:
                  self.restore_copies = [
                      args[i].clone() for i in self.restore_idx
                  ]
  
          self.pre_hook = _pre_hook
      if len(self.restore_idx) > 0:
  
          def _post_hook(args):
              for i, j in enumerate(self.restore_idx):
                  args[j].copy_(self.restore_copies[i])
              self.restore_copies = []
  
          self.post_hook = _post_hook
  
      self.perf_model = None
      self.configs_top_k = 1.0
      self.early_config_prune = None
      if prune_configs_by:
          self.perf_model = prune_configs_by.get(
              "perf_model", self.perf_model
          )
          self.configs_top_k = prune_configs_by.get(
              "top_k", self.configs_top_k
          )
          self.early_config_prune = prune_configs_by.get(
              "early_config_prune", self.early_config_prune
          )
  
      self.fn = fn
      self.num_warmups = warmup
      self.num_reps = rep
  
imports: from __future__ import annotations
  import builtins
  import time
  from typing import Dict
  from ..testing import do_bench
  from .jit import KernelInterface
label_desc: Use image node_id 1 to create a new Autotuner object from inherited base classes: KernelInterface with example: obj = Autotuner(fn, arg_names, configs, key, reset_to_zero, restore_value, prune_configs_by, warmup, rep)