Skip to content
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

clearState() of SpatialFullConvolution is missing input_slice / output_slice #313

Closed
sniklaus opened this Issue Jan 17, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@sniklaus
Copy link

sniklaus commented Jan 17, 2017

The clearState() of SpatialConvolution contains the following line:

nn.utils.clear(self, '_input', '_gradOutput', 'input_slice', 'output_slice')

This line is missing in the clearState() of SpatialFullConvolution. While _input and _gradOutput are used to make the respective tensors contiguous and I do not see them being used in SpatialFullConvolution, the input_slice and the output_slice seem to be used and are thus not being cleared.

It might be useful to move some of this functionality into the clearDesc() of SpatialConvolution, which is also called by SpatialFullConvolution.

@ngimel

This comment has been minimized.

Copy link
Collaborator

ngimel commented Feb 4, 2017

Input_slice and output_slice share storage with input and output respectively, so there is no need to clear them separately.

@sniklaus

This comment has been minimized.

Copy link
Author

sniklaus commented Feb 4, 2017

Are you sure that there is nothing wrong? The following ends up saving over 200 megabytes.

require 'cudnn'

input = torch.rand(1000, 10, 32, 32):cuda()
gradInput = torch.rand(1000, 10, 16, 16):cuda()

net = cudnn.SpatialFullConvolution(10, 10, 4, 4, 2, 2, 1, 1):cuda()

net:forward(input)
net:backward(input, gradInput)

torch.save('net.t7', net:clearState())
@ngimel

This comment has been minimized.

Copy link
Collaborator

ngimel commented Feb 4, 2017

Ah, you are right. Perhaps SpatialFullConvolution's clearState should just call SpatialConvolution's clearState.

borisfom added a commit to NVIDIA/torch-cudnn that referenced this issue Feb 6, 2017

borisfom added a commit to NVIDIA/torch-cudnn that referenced this issue Feb 10, 2017

@soumith soumith closed this in #327 Feb 10, 2017

soumith added a commit that referenced this issue Feb 10, 2017

@shamangary

This comment has been minimized.

Copy link

shamangary commented Jul 18, 2017

SpatialConvolution has the similar issue, but it is actually an issue of cudnn.convert().
(Or you can say the problem is about the clearState() under nn.)

If you have a trained model which is cudnn based and you convert it to nn by cudnn.convert(model,nn), input_slice and output_slice will not be clear by clearState() under nn.

You have to convert it back to cudnn and then do clearState() and then convert it back to nn.
I hope this can be fixed......

elikosan added a commit to elikosan/cudnn.torch that referenced this issue Jan 2, 2018

elikosan added a commit to elikosan/cudnn.torch that referenced this issue Jan 2, 2018

elikosan added a commit to elikosan/cudnn.torch that referenced this issue Jan 2, 2018

elikosan added a commit to elikosan/cudnn.torch that referenced this issue Jan 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.