Repository navigation
Add support for arrayanalysis of tuple args. #7398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
36a9da7
85e5548
c3406ce
435d434
6be6198
96981f2
1f922eb
98a6923
68047d3
cdd7a26
8c06789
29c1440
ed34eb5
99dec34
391893a
e39f6c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1873,10 +1873,18 @@ def _type_getitem(self, args): | |
| return self.pass_states.typingctx.resolve_function_type(fnty, tuple(args), {}) | ||
|
|
||
|
|
||
| def _make_index_var(typemap, scope, index_vars, body_block): | ||
| def _make_index_var(typemap, scope, index_vars, body_block, force_tuple=False): | ||
|
DrTodd13 marked this conversation as resolved.
Resolved
|
||
| """ When generating a SetItem call to an array in a parfor, the general | ||
| strategy is to generate a tuple if the array is more than 1 dimension. | ||
| If it is 1 dimensional then you can use a simple variable. This routine | ||
| is also used when converting pndindex to parfor but pndindex requires a | ||
| tuple even if the iteration space is 1 dimensional. The pndindex use of | ||
| this function will use force_tuple to make the output index a tuple even | ||
| if it is one dimensional. | ||
| """ | ||
| ndims = len(index_vars) | ||
| loc = body_block.loc | ||
| if ndims > 1: | ||
| if ndims > 1 or force_tuple: | ||
| tuple_var = ir.Var(scope, mk_unique_var( | ||
| "$parfor_index_tuple_var"), loc) | ||
| typemap[tuple_var.name] = types.containers.UniTuple( | ||
|
|
@@ -2446,11 +2454,20 @@ def find_mask_from_size(size_var): | |
| in_arr, mask_var, mask_typ, mask_indices = result | ||
| else: | ||
| in_arr = args[0] | ||
| size_vars = equiv_set.get_shape(in_arr | ||
| if mask_indices is None else mask_var) | ||
| index_vars, loops = _mk_parfor_loops( | ||
| pass_states.typemap, size_vars, scope, loc, | ||
| ) | ||
| assert(isinstance(in_arr, ir.Var)) | ||
| in_arr_typ = pass_states.typemap[in_arr.name] | ||
| if isinstance(in_arr_typ, types.Integer): | ||
| index_var = ir.Var(scope, mk_unique_var("parfor_index"), loc) | ||
| pass_states.typemap[index_var.name] = types.uintp | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not to be fixed in this PR. But I noticed that both @njit(parallel=True)
def test_impl(x, sz):
for i in pndindex(sz):
x[i] = 1
return x
print(test_impl(np.zeros((10, 10)), -3))
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tracked in #7462 |
||
| loops = [LoopNest(index_var, 0, in_arr, 1)] | ||
| index_vars = [index_var] | ||
| else: | ||
| size_vars = equiv_set.get_shape(in_arr | ||
| if mask_indices is None else mask_var) | ||
| index_vars, loops = _mk_parfor_loops( | ||
| pass_states.typemap, size_vars, scope, loc, | ||
| ) | ||
| assert(len(loops) > 0) | ||
| orig_index = index_vars | ||
| if mask_indices: | ||
| # replace mask indices if required; | ||
|
|
@@ -2462,6 +2479,7 @@ def find_mask_from_size(size_var): | |
| body_block = ir.Block(scope, loc) | ||
| index_var, index_var_typ = _make_index_var( | ||
| pass_states.typemap, scope, index_vars, body_block, | ||
| force_tuple=True | ||
| ) | ||
| body = body_block.body + first_body_block.body | ||
| first_body_block.body = body | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.