MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / __deepcopy__

Method __deepcopy__

deepspeed/module_inject/layers.py:623–636  ·  view source on GitHub ↗
(self, memo)

Source from the content-addressed store, hash-verified

621 return torch.cat([shards[i].narrow(dim, 0, size) for i, size in enumerate(partition_sizes)], dim=dim)
622
623 def __deepcopy__(self, memo):
624 # This function is designed for
625 # 'mp_group' (a 'ProcessGroup') cannot be pickled during deepcopy in some usage.
626 cls = self.__class__
627 new_obj = cls.__new__(cls)
628
629 for key, value in vars(self).items():
630 if key == 'mp_group':
631 new_obj.mp_group = self.mp_group
632 else:
633 setattr(new_obj, key, deepcopy(value, memo))
634
635 memo[id(self)] = new_obj
636 return new_obj
637
638 def extra_repr(self):
639 out_features, in_features = None, None

Callers

nothing calls this directly

Calls 1

__new__Method · 0.45

Tested by

no test coverage detected