-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Fix scatter size check #2960
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
Fix scatter size check #2960
Conversation
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.
64084f6 to
f0d6178
Compare
|
Updated cuda side error msg with size information. |
apaszke
left a comment
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.
Didn't finish reviewing. Just asking for comments
| #define TH_TENSOR_DIM_APPLY_INC | ||
|
|
||
| #define TH_TENSOR_DIM_APPLY3(TYPE1, TENSOR1, TYPE2, TENSOR2, TYPE3, TENSOR3, DIMENSION, CODE) \ | ||
| #define TH_TENSOR_DIM_APPLY3_SIZE_EQ_EXCEPT_DIM(TENSOR1, TENSOR2, TENSOR3, DIMENSION) \ |
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.
apaszke
left a comment
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.
Either I don't understand something, or it's not a complete fix for the issue linked. Some size checks seem to be unnecessarily strict, and the main issue mentioned there is that we accept 2 as index for the 0th dim, even if it's out of bound. This requires us to inspect the index data, which is not done in this PR.
| "Input tensor must have same size as output tensor apart from the specified dimension"); | ||
| THArgCheck(indexSizeD <= THCTensor_(size)(state, tensor, d), 3, | ||
| "Index tensor must not have larger size than output tensor apart from the specified dimension %d, but got index %s output %s", | ||
| dim, THCudaLongTensor_sizeDesc(state, index).str, THCTensor_(sizeDesc)(state, tensor).str); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| "Index tensor must not have larger size than output tensor apart from the specified dimension %d, but got index %s output %s", | ||
| dim, THCudaLongTensor_sizeDesc(state, index).str, THCTensor_(sizeDesc)(state, tensor).str); | ||
| } | ||
| THArgCheck(indexSizeD <= THCTensor_(size)(state, src, d), 3, |
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.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
According to my understanding of The issue linked is talking about the size relation between I wonder how scatter can be used to repeat elements. If I understand correctly, it can only copy each value to a certain position. I think you might be talking about |
|
Yeah I might have confused some parts with |
|
I just tested. Both CPU and CUDA version will throw error in that case. :) |
Fixes #1653
This ensures the following condition on
scatterfor both cpu and cuda:The drawback is introducing a weird macro argument. Let me know if I should think of other ways,