"vscode:/vscode.git/clone" did not exist on "61591b13e24f1e6377ef37c7f777e499f0840a06"
support scripting for torchscript ExportMethod
Summary: Pull Request resolved: https://github.com/facebookresearch/d2go/pull/118 This diff adds the proper support for using scripting when exporting model. Rename tracing-related code: - Previously `trace_and_save_torchscript` is the primary function to export model, replace it with `export_optimize_and_save_torchscript`. - Also rename `D2 (https://github.com/facebookresearch/d2go/commit/7992f91324aee6ae59795063a007c6837e60cdb8)TorchscriptTracingExport` to `TracingAdaptedTorchscriptExport` since it's not only for tracing now. Introduce `jit_mode`: - Add `jit_mode` option as the `export_kwargs` of ExportMethod. - Add `scripting` and `tracing` trigger words to overwrite `jit_mode`. Please note that the `tracing` now applies to all models, which is different from the previous meaning (using `TracingAdapter` for RCNN). - Therefore there're two ways of using scripting mode, 1) setting `jit_mode` in prepare_for_export; 2) using `script` trigger words. Add unit test as examples to illustrate two ways. - Don't use `TracingAdapter` when scripting since it's not scriptable. Consolidate triggering words logic. - Group logic of handling trigger words (eg. `_mobile`, `_int8`, `scripting`, `tracing`) into a single decorator `update_export_kwargs_from_export_method` for better structuring and readability. Reviewed By: zhanghang1989 Differential Revision: D31181624 fbshipit-source-id: 5fbb0d4fa4c29ffa4a761af8ea8f93b4bad4cef9
Showing
Please register or sign in to comment