Skip to content
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

Advanced indexing #235

Merged
merged 36 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
867f7a3
adding support for Adwance Indexing case when several index arrays a…
ipdemes Feb 17, 2022
2357166
adding more tests for advanced indexing
ipdemes Mar 11, 2022
abc583e
addressing dimension mismatch case
ipdemes Mar 11, 2022
3925e52
adding broadcasting for index arrays
ipdemes Mar 14, 2022
e7708c7
adding advanced_indexing task
ipdemes Mar 15, 2022
6b4acf1
extended ZIP task to support case when index.ndim < self.ndim
ipdemes Mar 17, 2022
51c5f50
adding support for the mixed type of the arguments
ipdemes Mar 17, 2022
2d6a671
adding support for number of arrays passed as indices< self.ndim
ipdemes Mar 18, 2022
3118969
adding support for the use case arr[:, indx, :]
ipdemes Mar 18, 2022
b87c51b
some clean-up
ipdemes Mar 18, 2022
d06e03d
adding support for some corner cases in the advanced indexing
ipdemes Mar 24, 2022
7672be1
adding support for advanced indexing in-place assignment with views t…
ipdemes Mar 28, 2022
d5e0446
registering all PointN types during the Runtime initialization
ipdemes Apr 5, 2022
6e1b4f1
fixing logic for transpose operation in advanced indexing
ipdemes Apr 5, 2022
76c1ae5
fixing an issue when advanced indexing operation is performed on tran…
ipdemes Apr 6, 2022
acdae9d
adapting to the output region API change
ipdemes Apr 7, 2022
6cab1ca
addressing PR comments
ipdemes Apr 11, 2022
9480cc0
some code clean-up + more tests
ipdemes Apr 12, 2022
02864d5
addressing PR comments for AdvancedIndexing task
ipdemes Apr 13, 2022
1772c0e
Merge remote-tracking branch 'gitrepo/branch-22.05' into advanced_ind…
ipdemes Apr 13, 2022
c69897f
addressing some PR comments on cunumeric/deferred
ipdemes Apr 14, 2022
e2bbcb5
addressing some PR comments on cunumeric/deferred 2
ipdemes Apr 14, 2022
a8bf6ad
cleaning up deferred.py
ipdemes Apr 15, 2022
04a3cc4
making zip task to compile for the case when Legion is compiled with …
ipdemes Apr 15, 2022
173f47f
Removing the cehck for the output_rect == input_rect
ipdemes Apr 18, 2022
3601cdb
cleaning-up tests + fixing logic for transformed rhs and index arrays
ipdemes Apr 18, 2022
502a4b2
removing unnecessary call to the FILL task
ipdemes Apr 19, 2022
7a33d9e
Merge remote-tracking branch 'gitrepo/branch-22.05' into advanced_ind…
ipdemes Apr 19, 2022
95ae53d
fixed the logic for transposing base array when bool arrays are passe…
ipdemes Apr 19, 2022
a3979dc
adding logic for the set_item when base array was transposed internally
ipdemes Apr 20, 2022
f7990ad
making set_item work for the case when any transformations are done …
ipdemes Apr 20, 2022
a444581
some code clean-up + documentation
ipdemes Apr 20, 2022
fb882d5
Merge remote-tracking branch 'gitrepo/branch-22.05' into advanced_ind…
ipdemes Apr 20, 2022
8796301
fixing some small issues
ipdemes Apr 21, 2022
30539a9
adding debugging checks for cuda task variants
ipdemes Apr 21, 2022
8704cb0
removing explicit alignment from the buffers
ipdemes Apr 21, 2022
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
17 changes: 15 additions & 2 deletions cunumeric/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,21 @@ def _convert_key(self, key, first=True):
elif isinstance(key, tuple) and first:
return tuple(self._convert_key(k, first=False) for k in key)
else:
# Otherwise convert it to a cuNumeric array and get the thunk
return convert_to_cunumeric_ndarray(key)._thunk
# Otherwise convert it to a cuNumeric array, check types
# and get the thunk
key = convert_to_cunumeric_ndarray(key)
if key.dtype != np.bool and not np.issubdtype(
key.dtype, np.integer
):
raise TypeError("index arrays should be int or bool type")
if key.dtype != np.bool and key.dtype != np.int64:
runtime.warn(
"converting index array to int64 type",
category=RuntimeWarning,
)
key = key.astype(np.int64)

return key._thunk

@add_boilerplate()
def __getitem__(self, key):
Expand Down
16 changes: 16 additions & 0 deletions cunumeric/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def destroy(self):
# Match these to CuNumericOpCode in cunumeric_c.h
@unique
class CuNumericOpCode(IntEnum):
ADVANCED_INDEXING = _cunumeric.CUNUMERIC_ADVANCED_INDEXING
ARANGE = _cunumeric.CUNUMERIC_ARANGE
BINARY_OP = _cunumeric.CUNUMERIC_BINARY_OP
BINARY_RED = _cunumeric.CUNUMERIC_BINARY_RED
Expand Down Expand Up @@ -115,6 +116,7 @@ class CuNumericOpCode(IntEnum):
WHERE = _cunumeric.CUNUMERIC_WHERE
WINDOW = _cunumeric.CUNUMERIC_WINDOW
WRITE = _cunumeric.CUNUMERIC_WRITE
ZIP = _cunumeric.CUNUMERIC_ZIP


# Match these to CuNumericUnaryOpCode in cunumeric_c.h
Expand Down Expand Up @@ -252,3 +254,17 @@ class CuNumericTunable(IntEnum):
NUM_PROCS = _cunumeric.CUNUMERIC_TUNABLE_NUM_PROCS
MAX_EAGER_VOLUME = _cunumeric.CUNUMERIC_TUNABLE_MAX_EAGER_VOLUME
HAS_NUMAMEM = _cunumeric.CUNUMERIC_TUNABLE_HAS_NUMAMEM


# Match these to CuNumericTypeCodes in cunumeric_c.h
@unique
class CuNumericTypeCodes(IntEnum):
CUNUMERIC_TYPE_POINT1 = _cunumeric.CUNUMERIC_TYPE_POINT1
CUNUMERIC_TYPE_POINT2 = _cunumeric.CUNUMERIC_TYPE_POINT2
CUNUMERIC_TYPE_POINT3 = _cunumeric.CUNUMERIC_TYPE_POINT3
CUNUMERIC_TYPE_POINT4 = _cunumeric.CUNUMERIC_TYPE_POINT4
CUNUMERIC_TYPE_POINT5 = _cunumeric.CUNUMERIC_TYPE_POINT5
CUNUMERIC_TYPE_POINT6 = _cunumeric.CUNUMERIC_TYPE_POINT6
CUNUMERIC_TYPE_POINT7 = _cunumeric.CUNUMERIC_TYPE_POINT7
CUNUMERIC_TYPE_POINT8 = _cunumeric.CUNUMERIC_TYPE_POINT8
CUNUMERIC_TYPE_POINT9 = _cunumeric.CUNUMERIC_TYPE_POINT9
Loading