Commit 6d3a5fdb authored by Yuxin Wu's avatar Yuxin Wu Committed by Facebook GitHub Bot
Browse files

don't hard code device=cpu in exporter

Summary: make it an option

Differential Revision: D32601981

fbshipit-source-id: 308a0c49939531d840914aa8e256aae6db463929
parent 4826cd62
...@@ -30,6 +30,7 @@ def main( ...@@ -30,6 +30,7 @@ def main(
runner, runner,
# binary specific optional arguments # binary specific optional arguments
predictor_types: typing.List[str], predictor_types: typing.List[str],
device: str = "cpu",
compare_accuracy: bool = False, compare_accuracy: bool = False,
skip_if_fail: bool = False, skip_if_fail: bool = False,
): ):
...@@ -37,7 +38,7 @@ def main( ...@@ -37,7 +38,7 @@ def main(
setup_after_launch(cfg, output_dir, runner) setup_after_launch(cfg, output_dir, runner)
with temp_defrost(cfg): with temp_defrost(cfg):
cfg.merge_from_list(["MODEL.DEVICE", "cpu"]) cfg.merge_from_list(["MODEL.DEVICE", device])
model = runner.build_model(cfg, eval_only=True) model = runner.build_model(cfg, eval_only=True)
# NOTE: train dataset is used to avoid leakage since the data might be used for # NOTE: train dataset is used to avoid leakage since the data might be used for
...@@ -88,6 +89,7 @@ def run_with_cmdline_args(args): ...@@ -88,6 +89,7 @@ def run_with_cmdline_args(args):
runner, runner,
# binary specific optional arguments # binary specific optional arguments
predictor_types=args.predictor_types, predictor_types=args.predictor_types,
device=args.device,
compare_accuracy=args.compare_accuracy, compare_accuracy=args.compare_accuracy,
skip_if_fail=args.skip_if_fail, skip_if_fail=args.skip_if_fail,
) )
...@@ -101,6 +103,9 @@ def get_parser(): ...@@ -101,6 +103,9 @@ def get_parser():
nargs="+", nargs="+",
help="List of strings specify the types of predictors to export", help="List of strings specify the types of predictors to export",
) )
parser.add_argument(
"--device", default="cpu", help="the device to export the model on"
)
parser.add_argument( parser.add_argument(
"--compare-accuracy", "--compare-accuracy",
action="store_true", action="store_true",
......
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