Пример #1
0
 def remote_send(self, destination):
     """ Request the worker where the tensor being pointed to belongs to send it to destination.
     For instance, if C holds a pointer, ptr, to a tensor on A and calls ptr.remote_send(B),
     C will hold a pointer to a pointer on A which points to the tensor on B.
     """
     kwargs = {"inplace": True}
     message = TensorCommandMessage.communication(self.id_at_location,
                                                  self.location.id,
                                                  [destination.id], kwargs)
     self.owner.send_msg(message=message, location=self.location)
     return self
Пример #2
0
    def move(self, destination):
        kwargs = {"inplace": True, "create_pointer": False}
        message = TensorCommandMessage.communication(self.id_at_location,
                                                     self.location.id,
                                                     [destination.id], kwargs)
        self.owner.send_msg(message=message, location=self.location)

        # Change location of the pointer to point to the new object owner
        self.location = destination

        return self
Пример #3
0
 def remote_send(self, destination: AbstractWorker, requires_grad: bool = False):
     """Request the worker where the tensor being pointed to belongs to send it to destination.
     For instance, if C holds a pointer, ptr, to a tensor on A and calls ptr.remote_send(B),
     C will hold a pointer to a pointer on A which points to the tensor on B.
     Args:
         destination: where the remote value should be sent
         requires_grad: if true updating the grad of the remote tensor on destination B will
             trigger a message to update the gradient of the value on A.
     """
     kwargs_ = {"inplace": False, "requires_grad": requires_grad}
     message = TensorCommandMessage.communication(
         "remote_send", self, (destination.id,), kwargs_, (self.id,)
     )
     self.owner.send_msg(message=message, location=self.location)
     return self