mirror of
https://github.com/wassname/peft.git
synced 2026-09-11 12:30:16 +08:00
fix
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user