MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / __init__

Method __init__

python/oneflow/nn/graph/proxy.py:702–731  ·  view source on GitHub ↗
(
        self,
        origin: ModuleList = None,
        prefix: str = "",
        name: str = "",
        belonged_graph: weakref.ProxyTypes = None,
    )

Source from the content-addressed store, hash-verified

700
701class 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
734class ProxyModuleDict(get_dict(ProxyModule)):

Callers

nothing calls this directly

Calls 5

ModuleListClass · 0.85
__init__Method · 0.45
toMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected