syft.generic.object_storage¶
Module Contents¶
-
class
syft.generic.object_storage.ObjectStorage¶ A storage of objects identifiable by their id.
A wrapper object to a collection of objects where all objects are stored using their IDs as keys.
-
register_obj(self, obj: object, obj_id: Union[str, int] = None)¶ Registers the specified object with the current worker node.
Selects an id for the object, assigns a list of owners, and establishes whether it’s a pointer or not. This method is generally not used by the client and is instead used by internal processes (hooks and workers).
- Parameters
obj – A torch Tensor or Variable object to be registered.
obj_id (int or string) – random integer between 0 and 1e10 or
uniquely identifying the object. (string) –
-
de_register_obj(self, obj: object, _recurse_torch_objs: bool = True)¶ Deregisters the specified object.
Deregister and remove attributes which are indicative of registration.
- Parameters
obj – A torch Tensor or Variable object to be deregistered.
_recurse_torch_objs – A boolean indicating whether the object is more complex and needs to be explored. Is not supported at the moment.
-
get_obj(self, obj_id: Union[str, int])¶ Returns the object from registry.
Look up an object from the registry using its ID.
- Parameters
obj_id – A string or integer id of an object to look up.
- Returns
Object with id equals to obj_id.
-
set_obj(self, obj: Union[FrameworkTensorType, AbstractTensor])¶ Adds an object to the registry of objects.
- Parameters
obj – A torch or syft tensor with an id.
-
rm_obj(self, remote_key: Union[str, int])¶ Removes an object.
Remove the object from the permanent object registry if it exists.
- Parameters
remote_key – A string or integer representing id of the object to be removed.
-
force_rm_obj(self, remote_key: Union[str, int])¶ Forces object removal.
Besides removing the object from the permanent object registry if it exists. Explicitly forces removal of the object modifying the garbage_collect_data attribute.
- Parameters
remote_key – A string or integer representing id of the object to be removed.
-
clear_objects(self, return_self: bool = True)¶ Removes all objects from the object storage.
Note: the “return self” statement is kept in order to avoid modifying the code shown in the udacity course.
- Parameters
return_self – flag, whether to return self as return value
- Returns
self, if return_self if True, else None
-
current_objects(self)¶ Returns a copy of the objects in the object storage.
-