Beispiel #1
0
    def create_pointer(self,
                       owner,
                       garbage_collect_data,
                       location=None,
                       id_at_location=None,
                       tags=None,
                       **kwargs):
        """
        Create a pointer to the plan

        Args:
            owner: the owner of the pointer
            garbage_collect_data: if true, when the pointer is deleted, the remote target is garbaged collected
            location: the location of the pointer
            id_at_location: the remote id at location
            tags: the tags inherited from the Plan

        Returns:
            PointerPlan: pointer to the plan
        """
        return PointerPlan(
            owner=owner,
            location=location or self.owner,
            id_at_location=id_at_location or self.id,
            garbage_collect_data=garbage_collect_data,
            tags=tags,
        )
Beispiel #2
0
 def create_pointer(self, owner, garbage_collect_data):
     return PointerPlan(
         location=self.owner,
         id_at_location=self.id,
         owner=owner,
         garbage_collect_data=garbage_collect_data,
     )
Beispiel #3
0
 def create_pointer(
     self, owner, garbage_collect_data, location=None, id_at_location=None, **kwargs
 ):
     return PointerPlan(
         owner=owner,
         location=location or self.owner,
         id_at_location=id_at_location or self.id,
         garbage_collect_data=garbage_collect_data,
     )
Beispiel #4
0
def test_create_pointer_to_plan(workers):
    alice, bob, charlie = workers["alice"], workers["bob"], workers["charlie"]

    @sy.func2plan(args_shape=[(1, )], state={"bias": th.tensor([1.0])})
    def plan(x, state):
        bias = state.read("bias")
        return x + bias

    plan.send(alice)
    id_at_location = plan.id

    plan_ptr = PointerPlan(location=alice, id_at_location=id_at_location)

    x = th.tensor([1.0]).send(alice)

    ptr = plan_ptr(x)

    assert (ptr.get() == th.tensor([2.0])).all()
Beispiel #5
0
def test_create_pointer_to_plan(hook, workers):
    alice, bob, charlie = workers["alice"], workers["bob"], workers["charlie"]

    hook.local_worker.is_client_worker = False

    @sy.func2plan(args_shape=[(1, )], state=(th.tensor([1.0]), ))
    def plan(x, state):
        (bias, ) = state.read()
        return x + bias

    plan.send(alice)
    id_at_location = plan.id

    plan_ptr = PointerPlan(location=alice, id_at_location=id_at_location)

    x = th.tensor([1.0]).send(alice)

    ptr = plan_ptr(x)

    assert (ptr.get() == th.tensor([2.0])).all()

    hook.local_worker.is_client_worker = True