Skip to content

Commit

Permalink
Use dictionary unpacking instead of merge operator for python 3.8 com…
Browse files Browse the repository at this point in the history
…patibility (#4049)

The dictionary merge operator was introduced in Python 3.9 and
unfortunately PyTorch still supports 3.8. I think for this use case
there is no downside to unpacking, other than that it's a bit ugly.
  • Loading branch information
alexbaden authored Jun 1, 2024
1 parent 2126ae7 commit 03b8466
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions python/triton/runtime/autotuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,16 @@ def __init__(self, kwargs, num_warps=4, num_stages=2, num_ctas=1, maxnreg=None,
self.pre_hook = pre_hook

def all_kwargs(self):
return self.kwargs | {
k: v
for (k, v) in (
("num_warps", self.num_warps),
("num_ctas", self.num_ctas),
("num_stages", self.num_stages),
("maxnreg", self.maxnreg),
)
if v is not None
return {
**self.kwargs, **{
k: v
for (k, v) in (
("num_warps", self.num_warps),
("num_ctas", self.num_ctas),
("num_stages", self.num_stages),
("maxnreg", self.maxnreg),
) if v is not None
}
}

def __str__(self):
Expand Down

0 comments on commit 03b8466

Please sign in to comment.