KEMBAR78
Fix maxpool3d / avgpool3d crashs by zou3519 · Pull Request #5052 · pytorch/pytorch · GitHub
Skip to content

Conversation

@zou3519
Copy link
Contributor

@zou3519 zou3519 commented Feb 5, 2018

Fixes #4835. This PR picks up from #4848

There's a bug in THCDeviceTensor::downcastOuter where it sometimes doesn't recognize a contiguous tensor as being contiguous. This leads to crashes in maxpool3d, avgpool3d.

This PR removes usages of THCDeviceTensor::downcastOuter and replaces it with a call to newFoldBatchDim, which performs the same behavior of collapsing the batch and feature dims but uses newView internally.

cc @ssnl

Test Plan

New unit tests for maxpool3d and avgpool3d crashes. Run test_nn to make sure maxpool3d, avgpool3d, and maxunpool3d still work.

@zou3519 zou3519 changed the title Fix maxpool3d / avgpool3d / crashs Fix maxpool3d / avgpool3d crashs Feb 5, 2018
@soumith
Copy link
Member

soumith commented Feb 5, 2018

you're doing a double-free of a THCTensor somewhere. See contbuild.

Copy link
Collaborator

@ssnl ssnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks great. Could you also remove the now obsolete downcastOuter and downcastInner?

return self;
}

// Collapses the first two dimensions of a tensor

This comment was marked as off-topic.

@zou3519
Copy link
Contributor Author

zou3519 commented Feb 5, 2018

@ssnl I looked at the code for downcastOuter/inner and I'd rather not remove them in this PR because there are a lot of (also obsolete, I believe) functions that call them and it'll take a while to figure out everything that can be deleted. I'll save that for another PR

Copy link
Collaborator

@ssnl ssnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Merge-able when CI passes.

@soumith soumith merged commit a83c240 into pytorch:master Feb 6, 2018
@soumith soumith added the 0.3.1 label Feb 6, 2018
soumith pushed a commit that referenced this pull request Feb 7, 2018
* Replace downcastOuter with newFoldBatchDim

* Fix double free

* Address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants