def __init__( self, name: str = None, is_built: bool = False, forward_func=None, roles: Dict[str, Role] = {}, # General kwargs id: Union[str, int] = None, owner: "sy.workers.BaseWorker" = None, tags: List[str] = None, description: str = None, ): AbstractObject.__init__(self, id, owner, tags, description, child=None) # Protocol instance info self.name = name or self.__class__.__name__ self.roles = roles self.is_building = False self.state_attributes = {} self.is_built = is_built self.torchscript = None self.tracing = False if not hasattr(self, "forward"): self.forward = forward_func or None self.__name__ = self.__repr__() # For PyTorch jit tracing compatibility
def __init__( self, state: State = None, actions: List[Action] = None, placeholders: Dict[Union[str, int], PlaceHolder] = None, input_placeholder_ids: Tuple[int, str] = None, output_placeholder_ids: Tuple[int, str] = None, state_tensors=None, # General kwargs id: Union[str, int] = None, owner: "sy.workers.BaseWorker" = None, tags: List[str] = None, description: str = None, ): owner = owner or sy.local_worker AbstractObject.__init__(self, id, owner, tags, description, child=None) self.owner = owner self.actions = actions or [] self.state = state or State(owner=owner) # All placeholders self.placeholders = placeholders or {} # Input placeholders, stored by id self.input_placeholder_ids = input_placeholder_ids or () # Output placeholders self.output_placeholder_ids = output_placeholder_ids or () # state_tensors are provided when plans are created using func2plan if state_tensors: # we want to make sure in that case that the state is empty assert state is None for tensor in state_tensors: self.register_state_tensor(tensor)
def __init__( self, name: str = None, include_state: bool = False, is_built: bool = False, forward_func=None, state_tensors=None, role: Role = None, # General kwargs id: Union[str, int] = None, owner: "sy.workers.BaseWorker" = None, tags: List[str] = None, description: str = None, ): AbstractObject.__init__(self, id, owner, tags, description, child=None) # Plan instance info self.name = name or self.__class__.__name__ self.role = role or Role(state_tensors=state_tensors, owner=owner) self.include_state = include_state self.is_built = is_built self.torchscript = None # The plan has not been sent so it has no reference to remote locations self.pointers = dict() if not hasattr(self, "forward"): self.forward = forward_func or None self.__name__ = self.__repr__( ) # For PyTorch jit tracing compatibility
def __init__( self, name: str = None, state: State = None, include_state: bool = False, is_built: bool = False, actions: List[ComputationAction] = None, placeholders: Dict[Union[str, int], PlaceHolder] = None, forward_func=None, state_tensors=None, # General kwargs id: Union[str, int] = None, owner: "sy.workers.BaseWorker" = None, tags: List[str] = None, description: str = None, ): owner = owner or sy.local_worker AbstractObject.__init__(self, id, owner, tags, description, child=None) ObjectStorage.__init__(self) # Plan instance info self.name = name or self.__class__.__name__ self.owner = owner self.actions = actions or [] # Keep a local reference to all placeholders, stored by id self.placeholders = placeholders or {} # Incremental value to tag all placeholders with different tags self.var_count = 0 self.state = state or State(owner=owner) # state_tensors are provided when plans are created using func2plan if state_tensors is not None: # we want to make sure in that case that the state is empty assert state is None for tensor in state_tensors: placeholder = sy.PlaceHolder( tags={"#state", f"#{self.var_count + 1}"}, id=tensor.id, owner=self.owner) self.var_count += 1 placeholder.instantiate(tensor) self.state.state_placeholders.append(placeholder) self.placeholders[tensor.id] = placeholder self.include_state = include_state self.is_built = is_built # The plan has not been sent so it has no reference to remote locations self.pointers = dict() if not hasattr(self, "forward"): self.forward = forward_func or None self.__name__ = self.__repr__( ) # For PyTorch jit tracing compatibility
def __init__( self, name: str = None, include_state: bool = False, is_built: bool = False, forward_func=None, state_tensors=[], role: Role = None, # General kwargs id: Union[str, int] = None, owner: "sy.workers.BaseWorker" = None, tags: List[str] = None, input_types: list = None, description: str = None, ): AbstractObject.__init__(self, id, owner, tags, description, child=None) # Plan instance info self.name = name or self.__class__.__name__ self.role = role or Role() if role is None: for st in state_tensors: self.role.register_state_tensor(st) self.include_state = include_state self.is_building = False self.state_attributes = {} self.is_built = is_built self.torchscript = None self.input_types = input_types self.tracing = False # The plan has not been sent so it has no reference to remote locations self.pointers = dict() if not hasattr(self, "forward"): self.forward = forward_func or None """ When we use methods defined in a framework (like: torch.randn) we have a framework wrapper that helps as register and keep track of what methods are called With the below lines, we "register" what frameworks we have support to handle """ self.wrapped_framework = {} for f_name, f_packages in framework_packages.items(): self.wrapped_framework[f_name] = FrameworkWrapper( f_packages, self.role, self.owner) self.__name__ = self.__repr__( ) # For PyTorch jit tracing compatibility # List of available translations self.translations = []
def __init__( self, name: str = None, procedure: Procedure = None, state: State = None, include_state: bool = False, is_built: bool = False, # Optional kwargs if commands or state are not provided state_ids: List[Union[str, int]] = None, arg_ids: List[Union[str, int]] = None, result_ids: List[Union[str, int]] = None, readable_plan: List = None, blueprint=None, state_tensors=None, # General kwargs id: Union[str, int] = None, owner: "sy.workers.BaseWorker" = None, tags: List[str] = None, description: str = None, ): owner = owner or sy.local_worker AbstractObject.__init__(self, id, owner, tags, description, child=None) ObjectStorage.__init__(self) # Plan instance info self.name = name or self.__class__.__name__ self.owner = owner # If we have plans in plans we need to keep track of the states for each plan # because we will need to serialize and send them to the remote workers self.nested_states = [] # Info about the plan stored via the state and the procedure self.procedure = procedure or Procedure(readable_plan, arg_ids, result_ids) self.state = state or State(owner=owner, plan=self, state_ids=state_ids) if state_tensors is not None: for tensor in state_tensors: self.state.state_ids.append(tensor.id) self.owner.register_obj(tensor) self.include_state = include_state self.is_built = is_built self.input_shapes = None self._output_shape = None # The plan has not been sent self.pointers = dict() if blueprint is not None: self.forward = blueprint elif self.is_built: self.forward = None
def __init__( self, name: str = None, include_state: bool = False, is_built: bool = False, forward_func=None, state_tensors=[], role: Role = None, # General kwargs id: Union[str, int] = None, owner: "sy.workers.BaseWorker" = None, tags: List[str] = None, input_types: list = None, description: str = None, ): AbstractObject.__init__(self, id, owner, tags, description, child=None) # Plan instance info self.name = name or self.__class__.__name__ self.role = role or Role() if role is None: for st in state_tensors: self.role.register_state_tensor(st) self.include_state = include_state self.is_building = False self.state_attributes = {} self.is_built = is_built self.torchscript = None self.input_types = input_types self.validate_input_types = True self.tracing = False # The plan has not been sent so it has no reference to remote locations self.pointers = {} if not hasattr(self, "forward"): self.forward = forward_func or None self.__name__ = self.__repr__( ) # For PyTorch jit tracing compatibility # List of available translations self.translations = []
def __init__( self, name: str = None, procedure: Procedure = None, state: State = None, include_state: bool = False, is_built: bool = False, # Optional kwargs if commands or state are not provided state_ids: List[Union[str, int]] = None, arg_ids: List[Union[str, int]] = None, result_ids: List[Union[str, int]] = None, readable_plan: List = None, blueprint=None, state_tensors=None, # General kwargs id: Union[str, int] = None, owner: "sy.workers.BaseWorker" = None, tags: List[str] = None, description: str = None, ): owner = owner or sy.local_worker AbstractObject.__init__(self, id, owner, tags, description, child=None) ObjectStorage.__init__(self) # Plan instance info self.name = name or self.__class__.__name__ self.owner = owner # Info about the plan stored via the state and the procedure self.procedure = procedure or Procedure(readable_plan, arg_ids, result_ids) self.state = state or State( owner=owner, plan=self, state_ids=state_ids) if state_tensors is not None: for tensor in state_tensors: self.state.state_ids.append(tensor.id) self.owner.register_obj(tensor) self.include_state = include_state self.is_built = is_built if blueprint is not None: self.forward = blueprint elif self.is_built: self.forward = None