This commit is contained in:
Sourab Mangrulkar
2022-12-01 15:28:45 +05:30
parent 67d980f13b
commit 8920caeb1b
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -134,6 +134,13 @@ class PETModel(torch.nn.Module):
f"trainable params: {trainable_params} || all params: {all_param} || trainable%: {100 * trainable_params / all_param}"
)
def __getattr__(self, name: str):
"""Forward missing attributes to the wrapped module."""
try:
return super().__getattr__(name) # defer to nn.Module's logic
except AttributeError:
return getattr(self.base_model, name)
class PETModelForSequenceClassification(PETModel):
"""
+7
View File
@@ -116,3 +116,10 @@ class LoRAModel(torch.nn.Module):
def forward(self, *args, **kwargs):
return self.model(*args, **kwargs)
def __getattr__(self, name: str):
"""Forward missing attributes to the wrapped module."""
try:
return super().__getattr__(name) # defer to nn.Module's logic
except AttributeError:
return getattr(self.model, name)