(
self,
origin: ModuleList = None,
prefix: str = "",
name: str = "",
belonged_graph: weakref.ProxyTypes = None,
)
| 700 | |
| 701 | class ProxyModuleList(get_list(ProxyModule)): |
| 702 | def __init__( |
| 703 | self, |
| 704 | origin: ModuleList = None, |
| 705 | prefix: str = "", |
| 706 | name: str = "", |
| 707 | belonged_graph: weakref.ProxyTypes = None, |
| 708 | ): |
| 709 | if isinstance(origin, ModuleList): |
| 710 | super().__init__() |
| 711 | self.to(GraphModule)._name_prefix = prefix |
| 712 | self.to(GraphModule)._name = name |
| 713 | self.to(GraphModule)._belonged_graph = belonged_graph |
| 714 | self._oneflow_internal_graphblock__set_origin(origin) |
| 715 | # ModuleList is a container without forward() method, |
| 716 | |
| 717 | elif isinstance(origin, list): |
| 718 | super().__init__(origin) |
| 719 | first = origin[0] |
| 720 | new_name = "_idx" |
| 721 | new_list = [] |
| 722 | for item in origin: |
| 723 | new_name += "-" + item.to(GraphModule).name |
| 724 | new_list.append(item.to(Module)) |
| 725 | new_module_list = ModuleList(new_list) |
| 726 | self.to(GraphModule)._name_prefix = ( |
| 727 | first.to(GraphModule).name_prefix + first.to(GraphModule).name |
| 728 | ) |
| 729 | self.to(GraphModule)._name = new_name |
| 730 | self.to(GraphModule)._belonged_graph = first.to(GraphModule)._belonged_graph |
| 731 | self._oneflow_internal_origin__ = new_module_list |
| 732 | |
| 733 | |
| 734 | class ProxyModuleDict(get_dict(ProxyModule)): |
nothing calls this directly
no test coverage detected