[FRONTEND] using literal syntax to create the data structure (#1119)

The literal syntax can give minor performance bumps compared to function
calls to create dict, list and tuple. This name dict must be looked up
in the global scope in case it has rebound. The same goes for the other
two types list() and tuple().

Signed-off-by: nishantsikarwar <nsikarwar@ch.iitr.ac.in>
Co-authored-by: Philippe Tillet <phil@openai.com>
This commit is contained in:
Nishant Sikarwar
2023-02-04 03:29:13 +05:30
committed by GitHub
parent f86843f815
commit f9e26deb05
3 changed files with 5 additions and 5 deletions

View File

@@ -115,7 +115,7 @@ def _kernel(A, B, C, M, N, K,
class _matmul(torch.autograd.Function):
kernel = _kernel
_locks = dict()
_locks = {}
@staticmethod
def _call(a, b):

View File

@@ -18,11 +18,11 @@ class Autotuner(KernelInterface):
'prune_num_stages_by'(optional): a function used to prune num_stages. It take configs:List[Config] as its input, and returns pruned configs.
'''
if not configs:
self.configs = [Config(dict(), num_warps=4, num_stages=2)]
self.configs = [Config({}, num_warps=4, num_stages=2)]
else:
self.configs = configs
self.key_idx = [arg_names.index(k) for k in key]
self.cache = dict()
self.cache = {}
# hook to reset all required tensor to zeros before relaunching a kernel
self.hook = lambda args: 0
if reset_to_zero is not None:

View File

@@ -241,8 +241,8 @@ class JITFunction(KernelInterface[T]):
src = f"""
def {self.fn.__name__}({', '.join(self.arg_names)}, grid, num_warps=4, num_stages=3, extern_libs=None, stream=None, warmup=False):
sig_key = {sig_keys},
constexpr_key = {f'{constexpr_keys},' if len(constexpr_keys) > 0 else tuple()}
spec_key = {f'{spec_keys},' if len(spec_keys) > 0 else tuple()}
constexpr_key = {f'{constexpr_keys},' if len(constexpr_keys) > 0 else ()}
spec_key = {f'{spec_keys},' if len(spec_keys) > 0 else ()}
key = (version_key, sig_key, constexpr_key, spec_key)
if not extern_libs is None:
key = (key, tuple(extern_libs.items()))