Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numba_cuda/numba/cuda/core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
PYVERSION,
BINOPS_TO_OPERATORS,
INPLACE_BINOPS_TO_OPERATORS,
_lazy_pformat,
)
from numba.cuda.utils import _lazy_pformat
from numba.cuda.core.byteflow import Flow, AdaptDFA, AdaptCFA, BlockKind
from numba.cuda.core.unsafe import eh
from numba.cuda.cpython.unsafe.tuple import unpack_single_tuple
Expand Down
3 changes: 2 additions & 1 deletion numba_cuda/numba/cuda/core/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from numba.cuda.core import errors
from numba.cuda.core import ir_utils
from numba.cuda.core.analysis import compute_use_defs
from numba.core.utils import _lazy_pformat


_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -301,7 +302,7 @@ def loop_lifting(func_ir, typingctx, targetctx, flags, locals):
_logger.debug(
"loop lifting this IR with %d candidates:\n%s",
len(loopinfos),
func_ir.dump_to_string(),
_lazy_pformat(func_ir, lazy_func=lambda x: x.dump_to_string()),
)
for loopinfo in loopinfos:
lifted = _loop_lift_modify_blocks(
Expand Down
12 changes: 11 additions & 1 deletion numba_cuda/numba/cuda/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,12 +673,22 @@ def dump_llvm(fndesc, module):


class _lazy_pformat:
"""
Lazily generate strings that may be useful only for debugging.
pformat is the default formatter but you can pass lazy_func kwarg
to use a different formatter.
"""

def __init__(self, *args, **kwargs):
self.func = pformat
self.args = args
self.kwargs = kwargs
if "lazy_func" in kwargs:
self.func = kwargs["lazy_func"]
del kwargs["lazy_func"]

def __str__(self):
return pformat(*self.args, **self.kwargs)
return self.func(*self.args, **self.kwargs)


class _LazyJSONEncoder(json.JSONEncoder):
Expand Down