-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Labels
Description
Copies that involve advanced indexing are implemented with a scatter/gather copy. The current code ignores the transforms on the RegionFields, i.e. it doesn't take into account the translation from NumPy (local) index space (every view's indices start from 0) to Legion (global) index space (every subregion's indices start wherever that subregion is placed within the parent region).
In the general case the base, index and value arrays can all be views:
a = np.arange(10)
b = np.arange(10)
c = np.arange(9, -1, -1)
x = a[2:7][ c[5:10] ] # __get_item__
a[2:7][ c[5:10] ] = b[3:8] # __set_item__
The logic to handle the general case of __get_item__ might be:
- use the
RegionFieldbacking the newly created result array (which has no transform) asdstin the gather/scatter copy - use root of base array as
src - if neither the base nor the index array are views, use index array's
RegionFieldassrc_indirect - if only the index array is a view, materialize it as a new array, getting rid of any transforms (like doing
c[5:10] * 1above), use the final array assrc_indirect - otherwise, apply the base array's transform (
\x. x+2in the example above) on each element of the index array (the transform operation will naturally get rid of the index's transform, if any), use the output array assrc_indirect
And for __set_item__:
- use value array's
RegionFieldassrcin the gather/scatter copy - if the value array is a view, create a new field to materialize its transform (stores the mapping
0:5 -> 3:8for the example above), use that assrc_indirect - use root of base array as
dst - if neither the base nor the index array are views, use index array's
RegionFieldasdst_indirect - if only the index array is a view, materialize it as a new array, getting rid of any transforms (like doing
c[5:10] * 1above), use the final array asdst_indirect - otherwise, apply the base array's transform (
\x. x+2in the example above) on each element of the index array (the transform operation will naturally get rid of the index's transform, if any), use the output array asdst_indirect
The work on StanfordLegion/legion#705 would allow us to avoid materializing at least some of these fields.
Edit: add some more detail, enumerate more cases, fix typos
Reactions are currently unavailable