Commit 70f236a6 authored by Tong Xiao's avatar Tong Xiao Committed by Facebook GitHub Bot
Browse files

Fix a bug in export api that prevents setting specific kwargs for different backends

Summary:
Pull Request resolved: https://github.com/facebookresearch/d2go/pull/236

When exporting the model to different backend engines, users may set the `model_export_kwargs` for different backends.

The torchscript backend needs a placeholder `**export_kwargs` to allow the kwargs for other backends.

Frankly speaking, this mechanism of passing the same set of kwargs to different backends is confusing. Better to be refactored to the factory pattern with isolated kwargs.

Reviewed By: HarounH, wat3rBro

Differential Revision: D36140771

fbshipit-source-id: f327559c1d063c9ce914a9afe2c1acf77c2aa287
parent b117baf1
......@@ -405,8 +405,18 @@ class DefaultTorchscriptExport(ModelExportMethod):
export_method: Optional[str],
**export_kwargs,
):
expected_arguments = {
"jit_mode",
"torchscript_filename",
"mobile_optimization",
"_extra_files",
}
filtered_kwargs = {
k: v for k, v in export_kwargs.items() if k in expected_arguments
}
torchscript_filename = export_optimize_and_save_torchscript(
model, input_args, save_path, **export_kwargs
model, input_args, save_path, **filtered_kwargs
)
return {TORCHSCRIPT_FILENAME_KEY: torchscript_filename}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment