Skip to content
Merged
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
3 changes: 2 additions & 1 deletion numba_cuda/numba/cuda/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ def __init__(self, py_func, targetdescr, targetoptions, pipeline_class):
self.py_func = py_func
self.targetdescr = targetdescr
self.targetoptions = targetoptions
self.locals = {}
self.pysig = utils.pysignature(self.py_func)
self.pipeline_class = pipeline_class
# Remember key=(args, return_type) combinations that will fail
Expand Down Expand Up @@ -843,7 +844,7 @@ def _compile_core(self, args, return_type):
args=args,
return_type=return_type,
flags=flags,
locals={},
locals=self.locals,
pipeline_class=self.pipeline_class,
)
# Check typing error if object mode is used
Expand Down
15 changes: 15 additions & 0 deletions numba_cuda/numba/cuda/tests/cudapy/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,21 @@ def test_compile_to_invalid_error(self):
output=illegal_output,
)

def test_functioncompiler_locals(self):
# Tests against regression fixed in:
# https://github.com/NVIDIA/numba-cuda/pull/381
#
# "AttributeError: '_FunctionCompiler' object has no attribute
# 'locals'"
cond = None

@cuda.jit("void(float32[::1])")
def f(b_arg):
b_smem = cuda.shared.array(shape=(1,), dtype=float32)

if cond:
b_smem[0] = b_arg[0]


@skip_on_cudasim("Compilation unsupported in the simulator")
class TestCompileForCurrentDevice(CUDATestCase):
Expand Down