-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Handle copying empty sparse tensors to/from CPU, GPU. #5361
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
This is likely not a robust fix because it special cases the case where both the indices and values are empty rather than handling each one separately. But this is currently blocking a change introducing devices to constructors.
zou3519
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.
Looks good! I had one minor comment
| // TODO: we may need to special case when only one of these are empty. | ||
| if (THLongTensor_nDimension(indices) == 0 && THTensor_(nDimension)(values) == 0) { | ||
| nDimI = 0; | ||
| nDimV = THLongStorage_size(sizes); |
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.
| // TODO: we may need to special case when only one of these are empty. | ||
| if (THCudaLongTensor_nDimension(state, indices) == 0 && THCTensor_(nDimension)(state, values) == 0) { | ||
| nDimI = 0; | ||
| nDimV = THLongStorage_size(sizes); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
zou3519
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.
LGTM!
|
onnx failures are unrelated |
* Handle copying empty sparse tensors to/from CPU, GPU. This is likely not a robust fix because it special cases the case where both the indices and values are empty rather than handling each one separately. But this is currently blocking a change introducing devices to constructors. * Guard sizes being NULL.
This is likely not a robust fix because it special cases the case where both the indices and values are empty rather than handling each one separately. But this is currently blocking a change introducing devices to constructors.