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

Class Variable

test/dynamo/test_python_autograd.py:28–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27
28class Variable:
29 def __init__(self, value: torch.Tensor, name: str = None):
30 self.value = value
31 self.name = name or fresh_name()
32
33 # We need to start with some tensors whose values were not computed
34 # inside the autograd. This function constructs leaf nodes.
35 @staticmethod
36 def constant(value: torch.Tensor, name: str = None):
37 return Variable(value, name)
38
39 def __repr__(self):
40 return repr(self.value)
41
42 # This performs a pointwise multiplication of a Variable, tracking gradients
43 def __mul__(self, rhs: "Variable") -> "Variable":
44 # defined later in the notebook
45 return operator_mul(self, rhs)
46
47 def __add__(self, rhs: "Variable") -> "Variable":
48 return operator_add(self, rhs)
49
50 def sum(self, name: Optional[str] = None) -> "Variable":
51 return operator_sum(self, name)
52
53 def expand(self, sizes: List[int]) -> "Variable":
54 return operator_expand(self, sizes)
55
56
57class TapeEntry(NamedTuple):

Callers 15

test_indexingMethod · 0.90
test_inplaceMethod · 0.90
test_setitemMethod · 0.90
test_setitem_maskMethod · 0.90
test_type_conversionsMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_indexingMethod · 0.72
test_inplaceMethod · 0.72
test_setitemMethod · 0.72
test_setitem_maskMethod · 0.72
test_type_conversionsMethod · 0.72
forwardMethod · 0.72
forwardMethod · 0.72
forwardMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…