MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / insert

Method insert

imperative/python/megengine/traced_module/utils.py:242–260  ·  view source on GitHub ↗
(self, idx, mod: Module)

Source from the content-addressed store, hash-verified

240 return self._size
241
242 def insert(self, idx, mod: Module):
243 assert isinstance(mod, Module)
244 L = len(self)
245 if idx < 0:
246 idx = L - idx
247 # clip idx to (0, L)
248 if idx > L:
249 idx = L
250 elif idx < 0:
251 idx = 0
252
253 for new_idx in range(L, idx, -1):
254 orig_idx = new_idx - 1
255 key = self._ikey(new_idx)
256 setattr(self, key, self[orig_idx])
257
258 key = self._ikey(idx)
259 setattr(self, key, mod)
260 self._size += 1
261
262 def forward(self):
263 raise RuntimeError("ModuleList is not callable")

Callers 15

print_op_statsFunction · 0.45
print_activations_statsFunction · 0.45
unflatten_argsMethod · 0.45
check_builtin_moduleMethod · 0.45
bn_opdef_loaderFunction · 0.45
deconv_loaderFunction · 0.45
deconv3d_loaderFunction · 0.45
__exit__Method · 0.45
__setstate__Method · 0.45
reduce_scatter_sumFunction · 0.45
scatterFunction · 0.45
all_to_allFunction · 0.45

Calls 1

_ikeyMethod · 0.95

Tested by

no test coverage detected