export_with_logger#

composer.utils.export_with_logger(model, save_format, save_path, logger, save_object_store=None, sample_input=None, transforms=None, input_names=None, output_names=None)[source]#

Helper method for exporting a model for inference.

Exports the model to: 1) save_object_store, if one is provided, 2) logger.upload_file(save_path), if (1) does not apply and the logger has a destination that supports file uploading, 3) locally, if (1) and (2) do not apply.

Parameters
  • model (nn.Module) โ€“ An instance of nn.Module. Please note that model is not modified inplace. Instead, export-related transformations are applied to a copy of the model.

  • save_format (Union[str, ExportFormat]) โ€“ Format to export to. Either "torchscript" or "onnx".

  • save_path โ€“ (str): The path for storing the exported model. It can be a path to a file on the local disk,

  • URL (a) โ€“ in a cloud bucket. For example, my_run/exported_model.

  • set (or if save_object_store is) โ€“ in a cloud bucket. For example, my_run/exported_model.

  • name (the object) โ€“ in a cloud bucket. For example, my_run/exported_model.

  • logger (Logger) โ€“ If this logger has a destination that supports file uploading, and save_object_store is not provided, this logger is used to export the model.

  • save_object_store (ObjectStore, optional) โ€“ If the save_path is in an object name in a cloud bucket (i.e. AWS S3 or Google Cloud Storage), an instance of ObjectStore which will be used to store the exported model. Set this to None if the logger should be used to export the model or if save_path is a local filepath. (default: None)

  • sample_input (Any, optional) โ€“ Example model inputs used for tracing. This is needed for โ€œonnxโ€ export. The sample_input need not match the batch size you intend to use for inference. However, the model should accept the sample_input as is. (default: None)

  • transforms (Sequence[Transform], optional) โ€“ transformations (usually optimizations) that should be applied to the model. Each Transform should be a callable that takes a model and returns a modified model. transforms are applied after surgery_algs. (default: None)

  • input_names (Sequence[str], optional) โ€“ names to assign to the input nodes of the graph, in order. If set to None, the keys from the sample_input will be used. Fallbacks to ["input"].

  • output_names (Sequence[str], optional) โ€“ names to assign to the output nodes of the graph, in order. It set to None, it defaults to ["output"].

Returns

None