MCPcopy Create free account
hub / github.com/pytorch/tutorials / __init__

Method __init__

recipes_source/regional_compilation.py:82–91  ·  view source on GitHub ↗
(self, apply_regional_compilation)

Source from the content-addressed store, hash-verified

80
81class Model(torch.nn.Module):
82 def __init__(self, apply_regional_compilation):
83 super().__init__()
84 self.linear = torch.nn.Linear(10, 10)
85 # Apply compile only to the repeated layers.
86 if apply_regional_compilation:
87 self.layers = torch.nn.ModuleList(
88 [torch.compile(Layer()) for _ in range(64)]
89 )
90 else:
91 self.layers = torch.nn.ModuleList([Layer() for _ in range(64)])
92
93 def forward(self, x):
94 # In regional compilation, the self.linear is outside of the scope of `torch.compile`.

Callers

nothing calls this directly

Calls 2

LayerClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected