- 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)#
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.
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_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,
set (or if save_object_store is) – in a cloud bucket. For example,
name (the object) – in a cloud bucket. For example,
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_pathis in an object name in a cloud bucket (i.e. AWS S3 or Google Cloud Storage), an instance of
ObjectStorewhich will be used to store the exported model. Set this to
Noneif the logger should be used to export the model or if
save_pathis a local filepath. (default:
sample_input (Any, optional) – Example model inputs used for tracing. This is needed for “onnx” export. The
sample_inputneed not match the batch size you intend to use for inference. However, the model should accept the
sample_inputas is. (default:
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.
transformsare applied after
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
output_names (Sequence[str], optional) – names to assign to the output nodes of the graph, in order. It set to
None, it defaults to