Skip to content

Commit 528b6d0

Browse files
committed
Merge 'main' into vk/types
2 parents d87d44e + f6664ab commit 528b6d0

File tree

3 files changed

+7
-104
lines changed

3 files changed

+7
-104
lines changed

numba_cuda/numba/cuda/core/ssa.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from numba.cuda import config
2121
from numba.core import ir, errors
2222
from numba.cuda.core import ir_utils
23-
from numba.cuda.utils import OrderedSet, _lazy_pformat
23+
from numba.cuda.utils import _lazy_pformat
2424
from numba.cuda.core.analysis import compute_cfg_from_blocks
2525

2626

@@ -160,7 +160,7 @@ def _find_defs_violators(blocks, cfg):
160160
# Gather violators by number of definitions.
161161
# The violators are added by the order that they are seen and the algorithm
162162
# scan from the first to the last basic-block as they occur in bytecode.
163-
violators = OrderedSet([k for k, vs in defs.items() if len(vs) > 1])
163+
violators = {k: None for k, vs in defs.items() if len(vs) > 1}
164164
# Gather violators by uses not dominated by the one def
165165
doms = cfg.dominators()
166166
for k, use_blocks in uses.items():
@@ -169,9 +169,9 @@ def _find_defs_violators(blocks, cfg):
169169
dom = doms[label]
170170
def_labels = {label for _assign, label in defs[k]}
171171
if not def_labels.intersection(dom):
172-
violators.add(k)
172+
violators[k] = None
173173
break
174-
_logger.debug("SSA violators %s", _lazy_pformat(violators))
174+
_logger.debug("SSA violators %s", _lazy_pformat(list(violators)))
175175
return violators
176176

177177

numba_cuda/numba/cuda/lowering.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class BaseLower(object):
5050
def __init__(self, context, library, fndesc, func_ir, metadata=None):
5151
self.library = library
5252
self.fndesc = fndesc
53-
self.blocks = utils.SortedMap(func_ir.blocks.items())
53+
self.blocks = dict(sorted(func_ir.blocks.items()))
5454
self.func_ir = func_ir
5555
self.generator_info = func_ir.generator_info
5656
self.metadata = metadata
@@ -294,7 +294,7 @@ def lower_function_body(self):
294294
)
295295

296296
# Lower all blocks
297-
for offset, block in sorted(self.blocks.items()):
297+
for offset, block in self.blocks.items():
298298
bb = self.blkmap[offset]
299299
self.builder.position_at_end(bb)
300300
self.debug_print(f"# lower block: {offset}")

numba_cuda/numba/cuda/utils.py

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import threading
1818
import contextlib
1919
import json
20-
import typing as _tp
2120
from pprint import pformat
2221

2322
from types import ModuleType
@@ -35,7 +34,7 @@
3534

3635
from numba.cuda.core import config
3736

38-
from collections.abc import Mapping, Sequence, MutableSet, MutableMapping
37+
from collections.abc import Sequence
3938

4039
PYVERSION = config.PYVERSION
4140

@@ -354,102 +353,6 @@ def key(x):
354353
return order
355354

356355

357-
T = _tp.TypeVar("T")
358-
359-
360-
class OrderedSet(MutableSet[T]):
361-
def __init__(self, iterable: _tp.Iterable[T] = ()):
362-
# Just uses a dictionary under-the-hood to maintain insertion order.
363-
self._data = dict.fromkeys(iterable, None)
364-
365-
def __contains__(self, key):
366-
return key in self._data
367-
368-
def __iter__(self):
369-
return iter(self._data)
370-
371-
def __len__(self):
372-
return len(self._data)
373-
374-
def add(self, item):
375-
self._data[item] = None
376-
377-
def discard(self, item):
378-
self._data.pop(item, None)
379-
380-
381-
class MutableSortedSet(MutableSet[T], _tp.Generic[T]):
382-
"""Mutable Sorted Set"""
383-
384-
def __init__(self, values: _tp.Iterable[T] = ()):
385-
self._values = set(values)
386-
387-
def __len__(self):
388-
return len(self._values)
389-
390-
def __iter__(self):
391-
return iter(k for k in sorted(self._values))
392-
393-
def __contains__(self, x: T) -> bool:
394-
return self._values.__contains__(x)
395-
396-
def add(self, x: T):
397-
return self._values.add(x)
398-
399-
def discard(self, value: T):
400-
self._values.discard(value)
401-
402-
def update(self, values):
403-
self._values.update(values)
404-
405-
406-
Tk = _tp.TypeVar("Tk")
407-
Tv = _tp.TypeVar("Tv")
408-
409-
410-
class SortedMap(Mapping[Tk, Tv], _tp.Generic[Tk, Tv]):
411-
"""Immutable"""
412-
413-
def __init__(self, seq):
414-
self._values = []
415-
self._index = {}
416-
for i, (k, v) in enumerate(sorted(seq)):
417-
self._index[k] = i
418-
self._values.append((k, v))
419-
420-
def __getitem__(self, k):
421-
i = self._index[k]
422-
return self._values[i][1]
423-
424-
def __len__(self):
425-
return len(self._values)
426-
427-
def __iter__(self):
428-
return iter(k for k, v in self._values)
429-
430-
431-
class MutableSortedMap(MutableMapping[Tk, Tv], _tp.Generic[Tk, Tv]):
432-
def __init__(self, dct=None):
433-
if dct is None:
434-
dct = {}
435-
self._dct: dict[Tk, Tv] = dct
436-
437-
def __getitem__(self, k: Tk) -> Tv:
438-
return self._dct[k]
439-
440-
def __setitem__(self, k: Tk, v: Tv):
441-
self._dct[k] = v
442-
443-
def __delitem__(self, k: Tk):
444-
del self._dct[k]
445-
446-
def __len__(self) -> int:
447-
return len(self._dct)
448-
449-
def __iter__(self) -> int:
450-
return iter(k for k in sorted(self._dct))
451-
452-
453356
class UniqueDict(dict):
454357
def __setitem__(self, key, value):
455358
if key in self:

0 commit comments

Comments
 (0)