syft.frameworks.torch.torch_attributes

Module Contents

class syft.frameworks.torch.torch_attributes.TorchAttributes(torch: ModuleType, hook: ModuleType)

Bases: syft.generic.frameworks.attributes.FrameworkAttributes

Adds torch module related custom attributes.

TorchAttributes is a special class where all custom attributes related to the torch module can be added. Any global parameter, configuration, or reference relating to PyTorch should be stored here instead of attaching it directly to some other part of the global namespace.

The main reason we need this is because the hooking process occasionally needs to save global objects, notably including what methods to hook and what methods to NOT hook.

This will hold all necessary attributes PySyft needs.

Parameters
  • torch – A ModuleType indicating the torch module

  • hook – A TorchHook to stash

ALIAS = torch
Tensor
is_inplace_method(self, method_name)

Determine if a method is inplace or not.

Check if the method ends by _ and is not a __xx__, then stash for constant-time lookup.

Parameters

method_name – The name for the method.

Returns

Boolean denoting if the method is inplace or not.