| 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 |