-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Add check for slice shape match in index_copy_ and index_add_. #4342
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
Conversation
Emits a warning if slices have the same size but different shapes. (It shouldn't be allowed, but it was, so some code might be unknowingly depending on the behavior.) Also refactored argument checking code, including index_fill_.
|
For example, the following code would silently corrupt the memory, but now it Also, the following code generates a warning. (I'm not sure if anybody is |
|
Hi, did anyone have a chance to look at this? Thanks! |
|
@pytorchbot add to whitelist |
| "Source/destination tensor have different slice sizes (%ld vs %ld)", | ||
| dstSliceSize, srcSliceSize); | ||
|
|
||
| if (mismatch) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| for (int d = 0; d < srcDims; d++) { | ||
| if (d != dim) { | ||
| srcSliceSize *= src->size[d]; | ||
| if (!mismatch && dst->size[d] != src->size[d]) mismatch = true; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
thanks a lot @yongjik ! |
Emits a warning if slices have the same size but different shapes. (It shouldn't be allowed, but it was, so some code might be unknowingly depending on the behavior.) Also refactored argument checking code, including index_fill_.
|
I think there might be something wrong with the index_copy_ function in the 0.4.0 release. When I use the following command, it will generate error message. (Dimension mismatching.) But when I transpose A and B and change the dim argument from 1 to 0, then it works. |
Emits a warning if slices have the same size but different shapes. (It
shouldn't be allowed, but it was, so some code might be unknowingly depending on
the behavior.)
Also refactored argument checking code, including index_fill_.
This fixes #4213.