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

Method add_dep_oprs

imperative/python/megengine/utils/network.py:308–330  ·  view source on GitHub ↗
(self, *vars)

Source from the content-addressed store, hash-verified

306 )
307
308 def add_dep_oprs(self, *vars):
309 if len(vars) == 0:
310 vars = self.output_vars
311
312 assert all(isinstance(var, VarNode) for var in vars), "Only support add VarNode"
313
314 q = list(vars)
315 while len(q) > 0:
316 cur = q.pop(0)
317 if cur.owner is not None:
318 continue
319 if cur.name is None:
320 cur.name = cur.var.name
321 self.all_vars_map[cur.var.id] = cur
322 mge_opr = cur.var.owner
323 if get_opr_type(mge_opr) == "Host2DeviceCopy":
324 self._orig_inputs.extend(mge_opr.outputs)
325 cur.owner = self._add_opr(mge_opr)
326 if cur.owner is None:
327 cur.owner = self.all_oprs_map[mge_opr.id]
328 continue
329 q.extend(cur.owner.inputs)
330 return list(vars)
331
332 def modify_opr_names(self, modifier):
333 r"""Modifies names of operators **inplace**; useful for merging loaded

Callers 4

loadMethod · 0.95
add_outputMethod · 0.95
replace_varsMethod · 0.95
test_replace_oprFunction · 0.80

Calls 3

_add_oprMethod · 0.95
listFunction · 0.85
get_opr_typeFunction · 0.85

Tested by 1

test_replace_oprFunction · 0.64