|
29 | 29 | set_num_threads, get_num_threads, typeof) |
30 | 30 | from numba.core import (types, errors, ir, rewrites, |
31 | 31 | typed_passes, inline_closurecall, config, compiler, cpu) |
| 32 | +from numba.typed import Dict, List |
| 33 | + |
32 | 34 | from numba.extending import (overload_method, register_model, |
33 | 35 | typeof_impl, unbox, NativeValue, models) |
34 | 36 | from numba.core.registry import cpu_target |
@@ -230,6 +232,10 @@ def copy_args(*args): |
230 | 232 | new_args.append(copy.deepcopy(x)) |
231 | 233 | elif isinstance(x, list): |
232 | 234 | new_args.append(x[:]) |
| 235 | + elif isinstance(x, Dict): |
| 236 | + new_args.append(copy.copy(x)) |
| 237 | + elif isinstance(x, List): |
| 238 | + new_args.append(copy.copy(x)) |
233 | 239 | else: |
234 | 240 | raise ValueError('Unsupported argument type encountered') |
235 | 241 | return tuple(new_args) |
@@ -4082,6 +4088,11 @@ def test_impl(x, par, numthreads): |
4082 | 4088 | self.prange_tester(test_impl, x, par, 2) |
4083 | 4089 |
|
4084 | 4090 |
|
| 4091 | +@register_jitable |
| 4092 | +def test_call_hoisting_outcall(a,b): |
| 4093 | + return (a, b) |
| 4094 | + |
| 4095 | + |
4085 | 4096 | @skip_parfors_unsupported |
4086 | 4097 | class TestPrangeSpecific(TestPrangeBase): |
4087 | 4098 | """ Tests specific features/problems found under prange""" |
@@ -4421,6 +4432,34 @@ def test_impl(): |
4421 | 4432 |
|
4422 | 4433 | self.prange_tester(test_impl) |
4423 | 4434 |
|
| 4435 | + def test_tuple_hoisting(self): |
| 4436 | + # issue9529 |
| 4437 | + def test_impl(inputs): |
| 4438 | + outputs = [(Dict.empty(key_type=types.int64, value_type=types.float64), np.zeros(1)) for _ in range(len(inputs))] |
| 4439 | + for i in range(len(inputs)): |
| 4440 | + y = inputs[i] |
| 4441 | + out = np.zeros(1) |
| 4442 | + out[0] = i |
| 4443 | + outputs[i] = (inputs[i], out) |
| 4444 | + return outputs[0][1][0] |
| 4445 | + |
| 4446 | + N = config.NUMBA_NUM_THREADS + 1 |
| 4447 | + self.prange_tester(test_impl, [Dict.empty(key_type=types.int64, value_type=types.float64) for i in range(N)]) |
| 4448 | + |
| 4449 | + def test_call_hoisting(self): |
| 4450 | + # issue9529 |
| 4451 | + def test_impl(inputs): |
| 4452 | + outputs = [(Dict.empty(key_type=types.int64, value_type=types.float64), np.zeros(1)) for _ in range(len(inputs))] |
| 4453 | + for i in range(len(inputs)): |
| 4454 | + y = inputs[i] |
| 4455 | + out = np.zeros(1) |
| 4456 | + out[0] = i |
| 4457 | + outputs[i] = test_call_hoisting_outcall(inputs[i], out) |
| 4458 | + return outputs[0][1][0] |
| 4459 | + |
| 4460 | + N = config.NUMBA_NUM_THREADS + 1 |
| 4461 | + self.prange_tester(test_impl, [Dict.empty(key_type=types.int64, value_type=types.float64) for i in range(N)]) |
| 4462 | + |
4424 | 4463 | def test_record_array_setitem(self): |
4425 | 4464 | # issue6704 |
4426 | 4465 | state_dtype = np.dtype([('var', np.int32)]) |
|
0 commit comments