syft.generic.frameworks.attributes

Module Contents

class syft.generic.frameworks.attributes.FrameworkAttributes(framework: ModuleType, hook: FrameworkHook)

Bases: abc.ABC

property ALIAS(cls)
property Tensor(cls)

Default Tensor wrapper.

abstract is_inplace_method(self, method_name)

Determine if a method is inplace or not.

Framework-dependent, see subclasses for details.

Parameters

method_name – The name for the method.

Returns

Boolean denoting if the method is inplace or not.

_command_guard(self, command: str, get_native: bool = False)

Check command can be safely used.

Parameters
  • command – A string indicating command name.

  • get_native – A boolean parameter (default False) to indicate whether to return the command name or the native torch function. If False, return command name else return the native torch function.

Returns

The command name or a native framework function

_is_command_valid_guard(self, command: str)

Validate the command.

Indicates whether a command is valid with respect to the framework guard.

Parameters
  • command – A string indicating command to test.

  • framework_domain – A string indicating the framework domain or module in which the command is supposed to be, e.g. dir(torch), dir(torch.Tensor), dir(tensorflow), etc. (roughly)

Returns

A boolean indicating whether the command is valid.

classmethod get_native_framework_name(cls, attr: str)

Return the name of the native command for the given hooked command.

Parameters

attr – A string indicating the hooked command name (ex: torch.add)

Returns

torch.native_add)

Return type

The name of the native command (ex