Skip to content

Conversation

@szagoruyko
Copy link
Member

For backend switching mostly, see also the discussion here #526

self.finput = torch.Tensor()
self.fgradInput = torch.Tensor()
self.finput = self.finput and self.weight.new()
self.fgradInput = self.fgradInput and self.weight.new()
Copy link
Contributor

Choose a reason for hiding this comment

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

CPU and GPU version of SpatialConvolutionMM uses differently fgradInput (GPU assumes that fgradInput contains all ones). That's why it was being newly allocating this tensor. I think you should at least resize it to zero. See #211

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually think you should do it for finput as well (as it was before), because converting an already forwarded CPU model to GPU would create a huge (and unnecessary) finput buffer.

soumith added a commit that referenced this pull request Feb 9, 2016
Lazy initialization of buffers
@soumith soumith merged commit c733a88 into torch:master Feb 9, 2016
@soumith
Copy link
Member

soumith commented Feb 9, 2016

Thanks!

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