MCPcopy Create free account
hub / github.com/pytorch/pytorch / operator_sum

Function operator_sum

test/dynamo/test_python_autograd.py:167–179  ·  view source on GitHub ↗
(self: Variable, name: Optional[str])

Source from the content-addressed store, hash-verified

165
166
167def operator_sum(self: Variable, name: Optional[str]) -> "Variable":
168 r = Variable(torch.sum(self.value), name=name)
169 # print(f'{r.name} = {self.name}.sum()')
170
171 def propagate(dL_doutputs: List[Variable]):
172 (dL_dr,) = dL_doutputs
173 size = self.value.size()
174 return [dL_dr.expand(*size)]
175
176 gradient_tape.append(
177 TapeEntry(inputs=[self.name], outputs=[r.name], propagate=propagate)
178 )
179 return r
180
181
182def operator_expand(self: Variable, sizes: List[int]) -> "Variable":

Callers 1

sumMethod · 0.85

Calls 4

TapeEntryClass · 0.85
VariableClass · 0.70
sumMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…