This repository was archived by the owner on Sep 10, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +4
-21
lines changed Expand file tree Collapse file tree 2 files changed +4
-21
lines changed Original file line number Diff line number Diff line change @@ -486,27 +486,6 @@ def _load_model_state_dict(
486486 state_dict [new_key ] = state_dict .pop (key )
487487 return state_dict
488488
489- def __getattr__ (self , name ):
490- """
491- Rewrite __getattr__ to search attribute in Model and its model attribute.
492- Note that this is a temporary solution to expose internal model attributes to the user.
493-
494- :param name: The name of the attribute to get.
495- :return: The attribute value if found, otherwise raise AttributeError.
496- """
497- try :
498- if name in self .__dict__ :
499- return self .__dict__ [name ]
500- except AttributeError :
501- pass
502-
503- try :
504- return getattr (self .model , name )
505- except AttributeError :
506- raise AttributeError (
507- f"'{ type (self ).__name__ } ' object has no attribute '{ name } '"
508- )
509-
510489 @abstractmethod
511490 def forward (self , * args , ** kwargs ):
512491 raise NotImplementedError ("forward method is not implemented" )
Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ def _fqn_lookup(fqn: str, module: torch.nn.Module) -> Any:
5454 if fqn == "" :
5555 return module
5656 atoms = fqn .split ("." )
57+ # Expose the root module to users.
58+ # Note this is temporary, and will be removed once we removed Model.model
59+ if isinstance (module , Model ):
60+ module = module .model
5761 curr = module
5862 for a in atoms :
5963 curr = getattr (curr , a )
You can’t perform that action at this time.
0 commit comments