Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lambda o: sy.serde.msgpack.serde._detail(worker, o), protocol_tuple
)
def detail(worker: AbstractWorker, msg_tuple: tuple) -> "ObjectRequestMessage":
"""
This function takes the simplified tuple version of this message and converts
it into an ObjectRequestMessage. The simplify() method runs the inverse of this method.
Args:
worker (AbstractWorker): a reference to the worker necessary for detailing. Read
syft/serde/serde.py for more information on why this is necessary.
msg_tuple (Tuple): the raw information being detailed.
Returns:
ptr (ObjectRequestMessage): a ObjectRequestMessage.
Examples:
message = detail(sy.local_worker, msg_tuple)
"""
return ObjectRequestMessage(sy.serde.msgpack.serde._detail(worker, msg_tuple[0]))
def detail(worker: AbstractWorker, tensor_tuple: tuple) -> "PointerPlan":
# TODO: fix comment for this and simplifier
obj_id, id_at_location, worker_id, garbage_collect_data = tensor_tuple
obj_id = sy.serde.msgpack.serde._detail(worker, obj_id)
id_at_location = sy.serde.msgpack.serde._detail(worker, id_at_location)
worker_id = sy.serde.msgpack.serde._detail(worker, worker_id)
# If the pointer received is pointing at the current worker, we load the tensor instead
if worker_id == worker.id:
plan = worker.get_obj(id_at_location)
return plan
# Else we keep the same Pointer
else:
location = sy.hook.local_worker.get_worker(worker_id)
ptr = PointerPlan(
location=location,
id_at_location=id_at_location,
owner=worker,
state = sy.serde.msgpack.serde._detail(worker, state)
input_shapes = sy.serde.msgpack.serde._detail(worker, input_shapes)
output_shape = sy.serde.msgpack.serde._detail(worker, output_shape)
nested_states = sy.serde.msgpack.serde._detail(worker, nested_states)
plan = sy.Plan(owner=worker, id=id, include_state=include_state, is_built=is_built)
plan.nested_states = nested_states
plan.procedure = procedure
plan.state = state
state.plan = plan
plan.input_shapes = input_shapes
plan._output_shape = output_shape
plan.name = sy.serde.msgpack.serde._detail(worker, name)
plan.tags = sy.serde.msgpack.serde._detail(worker, tags)
plan.description = sy.serde.msgpack.serde._detail(worker, description)
return plan
"""
This function reconstructs a FixedPrecisionTensor given it's attributes in form of a tuple.
Args:
worker: the worker doing the deserialization
tensor_tuple: a tuple holding the attributes of the FixedPrecisionTensor
Returns:
FixedPrecisionTensor: a FixedPrecisionTensor
Examples:
shared_tensor = detail(data)
"""
tensor_id, field, base, precision_fractional, kappa, tags, description, chain = tensor_tuple
tensor = FixedPrecisionTensor(
owner=worker,
id=syft.serde.msgpack.serde._detail(worker, tensor_id),
field=field,
base=base,
precision_fractional=precision_fractional,
kappa=kappa,
tags=syft.serde.msgpack.serde._detail(worker, tags),
description=syft.serde.msgpack.serde._detail(worker, description),
)
if chain is not None:
chain = syft.serde.msgpack.serde._detail(worker, chain)
tensor.child = chain
return tensor
def detail(worker: AbstractWorker, tensor_tuple: tuple) -> "AdditiveSharingTensor":
"""
This function reconstructs a AdditiveSharingTensor given it's attributes in form of a tuple.
Args:
worker: the worker doing the deserialization
tensor_tuple: a tuple holding the attributes of the AdditiveSharingTensor
Returns:
AdditiveSharingTensor: a AdditiveSharingTensor
Examples:
shared_tensor = detail(data)
"""
tensor_id, field, crypto_provider, chain = tensor_tuple
crypto_provider = sy.serde.msgpack.serde._detail(worker, crypto_provider)
tensor = AdditiveSharingTensor(
owner=worker,
id=sy.serde.msgpack.serde._detail(worker, tensor_id),
field=field,
crypto_provider=worker.get_worker(crypto_provider),
)
if chain is not None:
chain = sy.serde.msgpack.serde._detail(worker, chain)
tensor.child = chain
return tensor
worker: the worker doing the deserialization
tensor_tuple: a tuple holding the attributes of the PromiseTensor
Returns:
PromiseTensor: a PromiseTensor
Examples:
shared_tensor = detail(data)
"""
id, shape, tensor_type, plans, tags, description = tensor_tuple
id = sy.serde.msgpack.serde._detail(worker, id)
shape = sy.serde.msgpack.serde._detail(worker, shape)
tensor_type = sy.serde.msgpack.serde._detail(worker, tensor_type)
plans = sy.serde.msgpack.serde._detail(worker, plans)
tags = sy.serde.msgpack.serde._detail(worker, tags)
description = sy.serde.msgpack.serde._detail(worker, description)
tensor = PromiseTensor(
owner=worker,
id=id,
shape=shape,
tensor_type=tensor_type,
plans=plans,
tags=tags,
description=description,
)
return tensor
def detail(worker: AbstractWorker, tensor_tuple: tuple) -> "PromiseTensor":
"""
This function reconstructs a PromiseTensor given it's attributes in form of a tuple.
Args:
worker: the worker doing the deserialization
tensor_tuple: a tuple holding the attributes of the PromiseTensor
Returns:
PromiseTensor: a PromiseTensor
Examples:
shared_tensor = detail(data)
"""
id, shape, tensor_type, plans, tags, description = tensor_tuple
id = sy.serde.msgpack.serde._detail(worker, id)
shape = sy.serde.msgpack.serde._detail(worker, shape)
tensor_type = sy.serde.msgpack.serde._detail(worker, tensor_type)
plans = sy.serde.msgpack.serde._detail(worker, plans)
tags = sy.serde.msgpack.serde._detail(worker, tags)
description = sy.serde.msgpack.serde._detail(worker, description)
tensor = PromiseTensor(
owner=worker,
id=id,
shape=shape,
tensor_type=tensor_type,
plans=plans,
tags=tags,
description=description,
)