Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add support for arrayanalysis of tuple args.
  • Loading branch information
DrTodd13 committed Sep 13, 2021
commit 36a9da79b9833d63ed539f232d7a5a212674f456
11 changes: 11 additions & 0 deletions numba/parfors/array_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,12 @@ def _analyze_inst(self, label, scope, equiv_set, inst, redefined):
shape = gvalue
elif isinstance(gvalue, int):
shape = (gvalue,)
elif isinstance(inst.value, ir.Arg):
if (
isinstance(typ, types.containers.UniTuple)
and isinstance(typ.dtype, types.Integer)
):
shape = inst.value

if isinstance(shape, ir.Const):
if isinstance(shape.value, tuple):
Expand Down Expand Up @@ -3128,11 +3134,16 @@ def _gen_shape_call(self, equiv_set, var, ndims, shape, post):
# attr call: A_sh_attr = getattr(A, shape)
if isinstance(shape, ir.Var):
shape = equiv_set.get_shape(shape)

# already a tuple variable that contains size
if isinstance(shape, ir.Var):
attr_var = shape
shape_attr_call = None
shape = None
elif isinstance(shape, ir.Arg):
attr_var = var
shape_attr_call = None
shape = None
else:
shape_attr_call = ir.Expr.getattr(var, "shape", var.loc)
attr_var = ir.Var(
Expand Down
7 changes: 7 additions & 0 deletions numba/tests/test_parfors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,13 @@ def test_impl(x):
x = np.ones((2, 2, 2, 2, 2, 15))
self.check(test_impl, x)

def test_tuple_arg(self):
def test_impl(x, sz):
for i in numba.pndindex(sz):
x[i] = 1
return x
sz = (10,10)
self.check(test_impl, np.empty(sz), sz)

@skip_parfors_unsupported
class TestParforsLeaks(MemoryLeakMixin, TestParforsBase):
Expand Down