nvflare.app_opt.pt.decomposers module

class SerializationModule(tensor)[source]

Bases: Module

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class TensorDecomposer[source]

Bases: ViaFileDecomposer

dump_to_file(items: dict, path: str, fobs_ctx: dict)[source]

Dump the items to the file with the specified path

Parameters:
  • items – a dict of items of target object type to be dumped to file

  • path – the path to the file.

  • fobs_ctx – FOBS Context

Returns: a tuple of (file name, meta info)

The “path” is a temporary file name. You should create the file with the specified name. However, some frameworks (e.g. numpy) may add a special suffix to the name. In this case, you must return the modified name.

The “items” is a dict of target objects. The dict contains all objects of the target type in one payload. The dict could be very big. You must create a file to contain all the objects.

get_bytes_dot() int[source]

Get the Datum Object Type to be used for bytes datum

Returns: the DOT for bytes datum

get_file_dot() int[source]

Get the Datum Object Type to be used for file ref datum

Returns: the DOT for file ref datum

load_from_file(path: str, fobs_ctx: dict, meta: dict | None = None) Any[source]

Load target object items from the specified file

Parameters:
  • path – the absolute path to the file to be loaded.

  • fobs_ctx – FOBS Context.

  • meta – meta info of the file.

Returns: a dict of target objects.

You must not delete the file after loading. Management of the file is done by the ViaFile class.

native_decompose(target: Tensor, manager: DatumManager | None = None) bytes[source]
native_recompose(data: bytes, manager: DatumManager | None = None) Tensor[source]
supported_type()[source]

Returns the type/class supported by this decomposer.

Returns:

The class (not instance) of supported type