-
Notifications
You must be signed in to change notification settings - Fork 70
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
adding bounds check for advanced indexing #397
Conversation
@ipdemes is this a complete PR? I don't see any changes on the Python side to make the exceptions re-raised. |
That is right, I didn't push changes to the python code |
I think we should throw the standard Python
|
@manopapad makes sense. Will change this |
src/cunumeric/index/zip.h
Outdated
@@ -45,6 +45,9 @@ class ZipTask : public CuNumericTask<ZipTask> { | |||
|
|||
constexpr coord_t compute_idx(coord_t index, coord_t dim) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the variable name dim
is very confusing. I believe you meant extent
, right? dim
seems synonymous with axis
in other contexts, so let's change this.
src/cunumeric/index/zip.h
Outdated
@@ -45,6 +45,9 @@ class ZipTask : public CuNumericTask<ZipTask> { | |||
|
|||
constexpr coord_t compute_idx(coord_t index, coord_t dim) | |||
{ | |||
// bounds checking | |||
if ((index < 0 && index + dim < 0) || (index >= 0 && index >= dim)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd actually rewrite this function to something like this:
coord_t sanitized_index = index < 0 ? index + dim : index;
if (sanitized_index < 0 || sanitized_index >= extent) throw ...
return sanitized_index;
@ipdemes merge this with the latest branch-22.07, then you won't see the failure on 2 GPUs anymore. |
done |
addressing issue #31