def register_transform_tensor( tensor: Union[torch.Tensor, AbstractTensor], owner: sy.workers.AbstractWorker = None) -> PointerTensor: """ Register a tensor and create a pointer that references it Args: tensor: the tensor owner: the owner make the registration Returns: the pointer """ assert owner is not None # FIXME: should be added automatically tensor.owner = owner owner.register_obj(tensor) pointer = tensor.create_pointer( location=owner, id_at_location=tensor.id, register=True, owner=owner, ptr_id=tensor.id, garbage_collect_data=False, ) return pointer
def register_tensor( tensor: Union[torch.Tensor, AbstractTensor], owner: sy.workers.AbstractWorker, response_ids: List = list(), ): """ Registers a tensor. Args: tensor: A tensor. owner: The owner that makes the registration. response_ids: List of ids where the tensor should be stored and each id is pop out when needed. """ tensor.owner = owner try: tensor.id = response_ids.pop(-1) except IndexError: raise ResponseSignatureError owner.register_obj(tensor)
def register_tensor( tensor: Union[torch.Tensor, AbstractTensor], response_ids: List = list(), owner: sy.workers.AbstractWorker = None, ) -> None: """ Register a tensor Args: tensor: the tensor response_ids: list of ids where the tensor should be stored and each id is pop out when needed owner: the owner that makes the registration Returns: the pointer """ assert owner is not None tensor.owner = owner try: tensor.id = response_ids.pop(-1) except IndexError: raise ResponseSignatureError owner.register_obj(tensor)