[lazy] support from_pretrained (#4801)

* [lazy] patch from pretrained

* [lazy] fix from pretrained and add tests

* [devops] update ci
This commit is contained in:
Hongxin Liu
2023-09-26 11:04:11 +08:00
committed by GitHub
parent 64a08b2dc3
commit 4965c0dabd
11 changed files with 397 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
from typing import Optional
from torch.nn import Module
__all__ = [
"get_pretrained_path",
"set_pretrained_path",
]
def get_pretrained_path(model: Module) -> Optional[str]:
return getattr(model, "_pretrained", None)
def set_pretrained_path(model: Module, path: str) -> None:
setattr(model, "_pretrained", path)