get_torch_modules

lib.infer.plugin_utils.get_torch_modules(obj: Any, mod: str | None = None, seen: set[int] | None = None, results: list[Module] | None = None) list[Module]

Recursively search a plugin’s model attribute to find any parent :class:`torch.nn.Module`s

Parameters:
  • obj (Any) – The object to check if it is a torch Module. This should be a plugin’s model attribute

  • mod (str | None) – The module that the parent model class belongs to. Default: None (Collected from the first object entered into the recursive function)

  • seen (set[int] | None) – A set of seen object IDs to prevent self-recursion. Default: None (Created when the first object enters the recursive function)

  • results (list[Module] | None) – List of discovered torch modules. Default: None (Created when the first object enters the recursive function)

Return type:

The list of discovered torch Modules