syft.generic.pointers.multi_pointer¶
Module Contents¶
-
class
syft.generic.pointers.multi_pointer.MultiPointerTensor(owner: BaseWorker = None, id: Union[str, int] = None, tags: List[str] = None, description: str = None, children: List[AbstractTensor] = [])¶ Bases:
syft.generic.tensor.AbstractTensorThe MultiPointerTensor gathers together several pointers to different locations which can be operated all at once. The pointers can be referencing the same value or a different one depending on the usage.
The MultiPointerTensor has the same structure that the AdditiveSharedTensor: its child attribute is a dictionary {worker.id: Pointer}
MultiPointerTensor can be directly instantiated using x.send(worker1, worker2, etc) where x is a syft or framework tensor. In that case, the value of x will be sent and replicated to each workers.
-
__str__(self)¶
-
property
grad(self, self_)¶
-
__eq__(self, other)¶
-
__add__(self, other)¶ Adding a MultiPointer (MPT) and an AdditiveShared Tensor (AST) should return an AdditiveShared Tensor, so if we have this configuration, we permute self and other to use the fact that other.__add__(…) return an object of type other
Else, we just redirect to .add which works well
-
__mul__(self, other)¶ See __add__ for details but, MPT * AST should return AST
-
property
shape(self)¶ This method returns the shape of the data being pointed to. This shape information SHOULD be cached on self._shape, but occasionally this information may not be present. If this is the case, then it requests the shape information from the remote object directly (which is inefficient and should be avoided).
-
dim(self)¶ This method fixes the error that the result of dim was a list of ints stored inside a multipointer tensor
-
get(self, sum_results: bool = False)¶
-
virtual_get(self, sum_results: bool = False)¶ Get the value of the tensor without calling get - Only for VirtualWorkers
-
static
dispatch(args, worker)¶ utility function for handle_func_command which help to select shares (seen as elements of dict) in an argument set. It could perhaps be put elsewhere
- Parameters
args – arguments to give to a functions
worker – owner of the shares to select
- Returns
args where the MultiPointerTensor are replaced by the appropriate share
-
classmethod
handle_func_command(cls, command)¶ Receive an instruction for a function to be applied on a Syft Tensor, Replace in the args all the LogTensors with their child attribute, forward the command instruction to the handle_function_command of the type of the child attributes, get the response and replace a Syft Tensor on top of all tensors found in the response.
- Parameters
command – instruction of a function command: (command name,
self>, arguments[, kwargs]) (<no) –
- Returns
the response of the function command
-
set_garbage_collect_data(self, value)¶
-
static
simplify(worker: AbstractWorker, tensor: MultiPointerTensor)¶ This function takes the attributes of a MultiPointerTensor and saves them in a tuple :param tensor: a MultiPointerTensor :type tensor: MultiPointerTensor
- Returns
a tuple holding the unique attributes of the additive shared tensor
- Return type
tuple
Examples
data = simplify(tensor)
-
static
detail(worker: AbstractWorker, tensor_tuple: tuple)¶ This function reconstructs a MultiPointerTensor given it’s attributes in form of a tuple. :param worker: the worker doing the deserialization :param tensor_tuple: a tuple holding the attributes of the MultiPointerTensor
- Returns
a MultiPointerTensor
- Return type
Examples
multi_pointer_tensor = detail(data)
-