Skip to content

Commit 5179b84

Browse files
committed
bunch of sporadic import fixes, cleanup soon
1 parent 0a60d27 commit 5179b84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+153
-134
lines changed

numba_cuda/numba/cuda/core/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ def reload_config():
643643

644644
# use numba.core.config if available, otherwise use numba.cuda.core.config
645645
try:
646-
import numba.core.config as _config # compat-ignore
646+
import numba.core.config as _config
647647

648648
sys.modules[__name__] = _config
649649
except ImportError:

numba_cuda/numba/cuda/core/entrypoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def init_all():
1717
If extensions have already been initialized, this function does nothing.
1818
"""
1919
if _HAS_NUMBA:
20-
from numba.core import entrypoints # compat-ignore
20+
from numba.core import entrypoints
2121

2222
entrypoints.init_all()
2323

numba_cuda/numba/cuda/core/inline_closurecall.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import copy
66
import ctypes
77
import numba.cuda.core.analysis
8+
from numba.cuda import _HAS_NUMBA
89
from numba.cuda import types, config, cgutils
910
from numba.cuda.core import ir
1011
from numba.cuda.core import errors
@@ -235,13 +236,11 @@ def check_reduce_func(func_ir, func_var):
235236
analysis"
236237
)
237238
if isinstance(reduce_func, (ir.FreeVar, ir.Global)):
238-
try:
239+
if _HAS_NUMBA:
239240
from numba.core.registry import CPUDispatcher
240241

241242
if not isinstance(reduce_func.value, CPUDispatcher):
242243
raise ValueError("Invalid reduction function")
243-
except ImportError:
244-
pass
245244

246245
# pull out the python function for inlining
247246
reduce_func = reduce_func.value.py_func
@@ -1043,17 +1042,6 @@ def codegen(context, builder, sig, args):
10431042
count_const = intp_t(tuplety.count)
10441043
return impl_ret_untracked(context, builder, intp_t, count_const)
10451044

1046-
return signature(types.intp, val), codegen
1047-
elif isinstance(val, types.ListTypeIteratorType):
1048-
1049-
def codegen(context, builder, sig, args):
1050-
(value,) = args
1051-
intp_t = context.get_value_type(types.intp)
1052-
from numba.typed.listobject import ListIterInstance
1053-
1054-
iterobj = ListIterInstance(context, builder, sig.args[0], value)
1055-
return impl_ret_untracked(context, builder, intp_t, iterobj.size)
1056-
10571045
return signature(types.intp, val), codegen
10581046
else:
10591047
msg = (

numba_cuda/numba/cuda/core/ir.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: BSD-2-Clause
33

4-
import numba
54
from collections import defaultdict
65
import copy
76
import itertools
@@ -15,6 +14,10 @@
1514
from functools import total_ordering
1615
from io import StringIO
1716

17+
from numba.cuda import _HAS_NUMBA
18+
19+
if _HAS_NUMBA:
20+
import numba
1821
from numba.cuda.core import errors
1922
from numba.cuda.core import config
2023
from numba.cuda.utils import UNARY_BUILTINS_TO_OPERATORS, OPERATORS_TO_BUILTINS

numba_cuda/numba/cuda/core/ir_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import warnings
1111

1212
import numba.cuda
13+
from numba.cuda import _HAS_NUMBA
1314
from numba.cuda import types
1415
from numba.cuda.core import ir
1516
from numba.cuda import typing
@@ -829,16 +830,14 @@ def has_no_side_effect(rhs, lives, call_table):
829830
):
830831
return True
831832

832-
try:
833+
if _HAS_NUMBA:
833834
from numba.core.registry import CPUDispatcher
834835
from numba.cuda.np.linalg import dot_3_mv_check_args
835836

836837
if isinstance(call_list[0], CPUDispatcher):
837838
py_func = call_list[0].py_func
838839
if py_func == dot_3_mv_check_args:
839840
return True
840-
except ImportError:
841-
pass
842841

843842
for f in remove_call_handlers:
844843
if f(rhs, lives, call_list):

numba_cuda/numba/cuda/core/sigutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from numba.cuda import types, typing, _HAS_NUMBA
55

66
if _HAS_NUMBA:
7-
from numba.core.typing import Signature as CoreSignature # compat-ignore
7+
from numba.core.typing import Signature as CoreSignature
88

99

1010
def is_signature(sig):

numba_cuda/numba/cuda/core/targetconfig.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from types import MappingProxyType
1414
from numba.cuda import utils
15+
from numba.cuda import _HAS_NUMBA
1516

1617

1718
class Option:
@@ -48,9 +49,9 @@ def doc(self):
4849
return self._doc
4950

5051

51-
try:
52+
if _HAS_NUMBA:
5253
from numba.core.targetconfig import ConfigStack, _FlagsStack
53-
except ImportError:
54+
else:
5455

5556
class _FlagsStack(utils.ThreadLocalStack, stack_name="flags"):
5657
pass

numba_cuda/numba/cuda/extending.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,12 @@ def decorate(overload_func):
219219
# For generic/CPU targets, also register in numba.core registry
220220
if target in ("generic", "cpu"):
221221
try:
222-
from numba.core.typing.templates import ( # compat-ignore
223-
make_overload_template as core_make_overload_template, # compat-ignore
224-
infer as core_infer, # compat-ignore
225-
infer_global as core_infer_global, # compat-ignore
226-
) # compat-ignore
227-
from numba.core import types as core_types # compat-ignore
222+
from numba.core.typing.templates import (
223+
make_overload_template as core_make_overload_template,
224+
infer as core_infer,
225+
infer_global as core_infer_global,
226+
)
227+
from numba.core import types as core_types
228228

229229
core_template = core_make_overload_template(
230230
func,
@@ -310,10 +310,10 @@ def decorate(overload_func):
310310
# For generic/CPU targets, also register in numba.core registry
311311
if target in ("generic", "cpu"):
312312
try:
313-
from numba.core.typing.templates import ( # compat-ignore
314-
make_overload_attribute_template as core_make_overload_attribute_template, # compat-ignore
315-
infer_getattr as core_infer_getattr, # compat-ignore
316-
) # compat-ignore
313+
from numba.core.typing.templates import (
314+
make_overload_attribute_template as core_make_overload_attribute_template,
315+
infer_getattr as core_infer_getattr,
316+
)
317317

318318
core_template = core_make_overload_attribute_template(
319319
typ, attr, overload_func, **kwargs
@@ -348,10 +348,10 @@ def decorate(overload_func):
348348
target = kwargs.get("target", "cuda")
349349
if target in ("generic", "cpu"):
350350
try:
351-
from numba.core.typing.templates import ( # compat-ignore
352-
make_overload_method_template as core_make_overload_method_template, # compat-ignore
353-
infer_getattr as core_infer_getattr, # compat-ignore
354-
) # compat-ignore
351+
from numba.core.typing.templates import (
352+
make_overload_method_template as core_make_overload_method_template,
353+
infer_getattr as core_infer_getattr,
354+
)
355355

356356
copied_kwargs2 = kwargs.copy()
357357
core_template = core_make_overload_method_template(

numba_cuda/numba/cuda/lowering.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: BSD-2-Clause
33

4-
import numba
54
from collections import namedtuple, defaultdict
65
import operator
76
import warnings
87
from functools import partial
98

109
from llvmlite import ir as llvm_ir
1110

11+
from numba.cuda import _HAS_NUMBA
1212
from numba.cuda.core import ir
1313
from numba.cuda import debuginfo, cgutils, utils, typing, types
1414
from numba.cuda.core import (
@@ -1880,7 +1880,14 @@ def _lit_or_omitted(value):
18801880
"""Returns a Literal instance if the type of value is supported;
18811881
otherwise, return `Omitted(value)`.
18821882
"""
1883+
excepts = LiteralTypingError
1884+
if _HAS_NUMBA:
1885+
from numba.core.errors import (
1886+
LiteralTypingError as CoreLiteralTypingError,
1887+
)
1888+
1889+
excepts = (LiteralTypingError, CoreLiteralTypingError)
18831890
try:
18841891
return types.literal(value)
1885-
except (LiteralTypingError, numba.core.errors.LiteralTypingError):
1892+
except excepts:
18861893
return types.Omitted(value)

numba_cuda/numba/cuda/misc/mergesort.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,24 @@
2323
)
2424

2525

26-
def make_mergesort_impl(wrap, lt=None, is_argsort=False):
27-
kwargs_lite = dict(no_cpython_wrapper=True, _nrt=False)
28-
26+
def make_mergesort_impl(lt=None, is_argsort=False):
2927
# The less than
3028
if lt is None:
3129

32-
@wrap(**kwargs_lite)
3330
def lt(a, b):
3431
return a < b
3532
else:
36-
lt = wrap(**kwargs_lite)(lt)
33+
lt = lt
3734

3835
if is_argsort:
3936

40-
@wrap(**kwargs_lite)
4137
def lessthan(a, b, vals):
4238
return lt(vals[a], vals[b])
4339
else:
4440

45-
@wrap(**kwargs_lite)
4641
def lessthan(a, b, vals):
4742
return lt(a, b)
4843

49-
@wrap(**kwargs_lite)
5044
def argmergesort_inner(arr, vals, ws):
5145
"""The actual mergesort function
5246
@@ -108,14 +102,12 @@ def argmergesort_inner(arr, vals, ws):
108102

109103
# The top-level entry points
110104

111-
@wrap(no_cpython_wrapper=True)
112105
def mergesort(arr):
113106
"Inplace"
114107
ws = np.empty(arr.size // 2, dtype=arr.dtype)
115108
argmergesort_inner(arr, None, ws)
116109
return arr
117110

118-
@wrap(no_cpython_wrapper=True)
119111
def argmergesort(arr):
120112
"Out-of-place"
121113
idxs = np.arange(arr.size)
@@ -129,8 +121,4 @@ def argmergesort(arr):
129121

130122

131123
def make_jit_mergesort(*args, **kwargs):
132-
from numba import njit
133-
134-
# NOTE: wrap with njit to allow recursion
135-
# because @register_jitable => @overload doesn't support recursion
136-
return make_mergesort_impl(njit, *args, **kwargs)
124+
return make_mergesort_impl(*args, **kwargs)

0 commit comments

Comments
 (0)