MCPcopy Create free account
hub / github.com/pytorch/executorch / get_lowered_module_name

Function get_lowered_module_name

exir/delegate.py:151–171  ·  view source on GitHub ↗

Adds the given lowered_module into the given root module and returns the name of the module added.

(
        root: torch.nn.Module,
        # pyre-ignore: Undefined or invalid type [11]: Annotation `LoweredBackendModule` is not defined as a type.
        lowered_module: LOWERED_BACKEND_MODULE_TYPE,  # noqa
    )

Source from the content-addressed store, hash-verified

149 return type(obj).__name__ == LOWERED_BACKEND_MODULE_TYPE
150
151 def get_lowered_module_name(
152 root: torch.nn.Module,
153 # pyre-ignore: Undefined or invalid type [11]: Annotation `LoweredBackendModule` is not defined as a type.
154 lowered_module: LOWERED_BACKEND_MODULE_TYPE, # noqa
155 ) -> str:
156 """
157 Adds the given lowered_module into the given root module and returns the
158 name of the module added.
159 """
160 # Find a qualifying name for the lowered submodule
161 qualname = None
162 i = 0
163 while True:
164 qualname = f"lowered_module_{i}"
165 if not hasattr(root, qualname):
166 break
167 i += 1
168 assert qualname is not None
169
170 root.add_module(qualname, lowered_module)
171 return qualname

Callers 3

programMethod · 0.90
trace_call_delegateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected