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

Function _copy_module

exir/program/_program.py:302–314  ·  view source on GitHub ↗
(new_prog, new_gm)

Source from the content-addressed store, hash-verified

300
301
302def _copy_module(new_prog, new_gm):
303 new_prog.meta.update(new_gm.meta)
304 new_prog.graph = new_gm.graph
305 submodules = [name for name, _ in new_prog.named_children()]
306 for name in submodules:
307 delattr(new_prog, name)
308 for name, mod in new_gm.named_children():
309 setattr(new_prog, name, mod)
310 for node in new_gm.graph.nodes:
311 if node.op == "get_attr":
312 t = getattr(new_gm, node.target, None)
313 if isinstance(t, torch.Tensor):
314 setattr(new_prog, node.target, t)
315
316
317def _create_empty_etrecord():

Callers 3

to_executorchMethod · 0.85
to_executorchMethod · 0.85

Calls 1

updateMethod · 0.45

Tested by 1