[Gemini] patch for supporting orch.add_ function for ColoTensor (#2003)

This commit is contained in:
Jiarui Fang
2022-11-25 20:06:35 +08:00
committed by GitHub
parent 632753abbc
commit 8daf1b4db1
7 changed files with 60 additions and 95 deletions

View File

@@ -16,14 +16,14 @@ class InlineOpModule(CheckpointModule):
def __init__(self, checkpoint=False) -> None:
super().__init__(checkpoint=checkpoint)
self.proj1 = nn.Linear(4, 8)
self.weight = nn.Parameter(torch.randn(8, 8))
self.proj2 = nn.Linear(8, 4)
self.proj2 = nn.Linear(8, 8)
def forward(self, x):
x = self.proj1(x)
# inline add_
x.add_(10)
x = F.linear(x, self.weight)
x = self.proj2(x)
# inline relu_
x = torch.relu_(x)
x = self.proj2(x)