mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Here's the command I used to invoke autopep8 (in parallel!): git ls-files | grep '\.py$' | xargs -n1 -P`nproc` autopep8 -i Several rules are ignored in setup.cfg. The goal is to let autopep8 handle everything which it can handle safely, and to disable any rules which are tricky or controversial to address. We may want to come back and re-enable some of these rules later, but I'm trying to make this patch as safe as possible. Also configures flake8 to match pep8's behavior. Also configures TravisCI to check the whole project for lint.
26 lines
696 B
Python
26 lines
696 B
Python
import torch
|
|
from .Module import Module
|
|
|
|
|
|
class Copy(Module):
|
|
|
|
def __init__(self, intype, outtype, dontCast=False):
|
|
self.dontCast = dontCast
|
|
super(Copy, self).__init__()
|
|
self.gradInput = intype()
|
|
self.output = outtype()
|
|
|
|
def updateOutput(self, input):
|
|
self.output.resize_(input.size()).copy_(input)
|
|
return self.output
|
|
|
|
def updateGradInput(self, input, gradOutput):
|
|
self.gradInput.resize_(gradOutput.size()).copy_(gradOutput)
|
|
return self.gradInput
|
|
|
|
def type(self, type=None, tensorCache=None):
|
|
if type and self.dontCast:
|
|
return self
|
|
|
|
return super(Copy, self).type(self, type, tensorCache)
|