Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions syft/frameworks/torch/tensors/interpreters/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,6 @@ def handle_func_command(cls, command):
except AttributeError:
pass

# TODO: clean this line
cmd = (
"syft.local_worker.hook."
+ ".".join(cmd.split(".")[:-1])
+ ".native_"
+ cmd.split(".")[-1]
)
# Run the native function with the new args
# Note the the cmd should already be checked upon reception by the worker
# in the execute_command function
Expand All @@ -341,10 +334,19 @@ def _get_response(cmd, args, kwargs):
"""
Return the evaluation of the cmd string parameter
"""
module = syft.local_worker.hook
segments = cmd.split(".")
submodules = segments[:-1]
command = segments[-1]

for sm in submodules:
module = getattr(module, sm)

command_method = getattr(module, f"native_{command}")
if isinstance(args, tuple):
response = eval(cmd)(*args, **kwargs)
response = command_method(*args, **kwargs)
else:
response = eval(cmd)(args, **kwargs)
response = command_method(args, **kwargs)

return response

Expand Down