MCPcopy
hub / github.com/NVIDIA/TensorRT-LLM / named_modules_with_parent

Method named_modules_with_parent

tensorrt_llm/module.py:116–141  ·  view source on GitHub ↗
(self, memo=None, prefix="", parent=None, remove_duplicate=True)

Source from the content-addressed store, hash-verified

114 yield m
115
116 def named_modules_with_parent(self, memo=None, prefix="", parent=None, remove_duplicate=True):
117 if memo is None:
118 memo = set()
119 if self not in memo:
120 if remove_duplicate:
121 memo.add(self)
122 yield prefix, self, parent
123
124 if parent:
125 # Use the up-to-date module from the parent, to allow replacing
126 # layers while iterating this generator.
127 module_name = prefix.rsplit(".", 1)[-1]
128 module = getattr(parent, module_name)
129 if module is None:
130 return
131 else:
132 module = self
133
134 for child_name, child_module in module._modules.items():
135 if child_module is None:
136 continue
137 submodule_prefix = prefix + ("." if prefix else "") + child_name
138 for m in child_module.named_modules_with_parent(
139 memo, submodule_prefix, module, remove_duplicate
140 ):
141 yield m
142
143 def named_children(self):
144 memo = set()

Callers 12

test_moduleMethod · 0.80
quantize_layersFunction · 0.80
smooth_quantize_pluginFunction · 0.80
fp8_rowwise_quantizeFunction · 0.80
qserve_quantizeFunction · 0.80
quantizeFunction · 0.80
fuse_gate_mlpFunction · 0.80
fuse_rg_lruFunction · 0.80
set_prompt_tuningFunction · 0.80
to_ootb_moeFunction · 0.80
parallelize_embeddingFunction · 0.80
optimize_cross_qkvFunction · 0.80

Calls 1

addMethod · 0.45

Tested by 1

test_moduleMethod · 0.64