How to convert detectron2 models into fx graph? #4610
Unanswered
seulkiyeom
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. I'd like to convert the models from detectron2 into fx graph toward the implementation on edge device.
Is there any way to do it?
I slightly modified a code tools/deploy/export_model.py for exporting the detectron2 model into fx graph
including
from torch.fx import symbolic_tracetraced = symbolic_trace(traceable_model)However, there is an error saying
Traceback (most recent call last):File "/mnt/ssd2/skyeom/anaconda3/envs/py39/lib/python3.9/runpy.py", line 197, in _run_module_as_mainreturn _run_code(code, main_globals, None,File "/mnt/ssd2/skyeom/anaconda3/envs/py39/lib/python3.9/runpy.py", line 87, in _run_codeexec(code, run_globals)File "/mnt/ssd2/skyeom/.vscode-server/extensions/ms-python.python-2022.16.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>cli.main()File "/mnt/ssd2/skyeom/.vscode-server/extensions/ms-python.python-2022.16.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in mainrun()File "/mnt/ssd2/skyeom/.vscode-server/extensions/ms-python.python-2022.16.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_filerunpy.run_path(target, run_name="__main__")File "/mnt/ssd2/skyeom/.vscode-server/extensions/ms-python.python-2022.16.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_pathreturn _run_module_code(code, init_globals, run_name,File "/mnt/ssd2/skyeom/.vscode-server/extensions/ms-python.python-2022.16.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code_run_code(code, mod_globals, init_globals,File "/mnt/ssd2/skyeom/.vscode-server/extensions/ms-python.python-2022.16.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_codeexec(code, run_globals)File "/mnt/ssd2/skyeom/PycharmProjects/detectron2/tools/deploy/export_model.py", line 237, in <module>exported_model = export_tracing(torch_model, sample_inputs)File "/mnt/ssd2/skyeom/PycharmProjects/detectron2/tools/deploy/export_model.py", line 128, in export_tracingtraced = symbolic_trace(traceable_model)File "/mnt/ssd2/skyeom/anaconda3/envs/py39/lib/python3.9/site-packages/torch/fx/_symbolic_trace.py", line 878, in symbolic_tracegraph = tracer.trace(root, concrete_args)File "/mnt/ssd2/skyeom/anaconda3/envs/py39/lib/python3.9/site-packages/torch/fx/_symbolic_trace.py", line 587, in traceself.create_node('output', 'output', (self.create_arg(fn(*args)),), {},File "/mnt/ssd2/skyeom/PycharmProjects/detectron2/detectron2/export/flatten.py", line 282, in forwardinputs_orig_format = self.inputs_schema(args)File "/mnt/ssd2/skyeom/PycharmProjects/detectron2/detectron2/export/flatten.py", line 91, in __call__return tuple(super().__call__(values))File "/mnt/ssd2/skyeom/PycharmProjects/detectron2/detectron2/export/flatten.py", line 73, in __call__values = self._split(values, self.sizes)File "/mnt/ssd2/skyeom/PycharmProjects/detectron2/detectron2/export/flatten.py", line 58, in _splitlen(values) == expected_lenFile "/mnt/ssd2/skyeom/anaconda3/envs/py39/lib/python3.9/site-packages/torch/fx/proxy.py", line 291, in __len__raise RuntimeError("'len' is not supported in symbolic tracing by default. If you want "RuntimeError: 'len' is not supported in symbolic tracing by default. If you want this call to be recorded, please call torch.fx.wrap('len') at module scopeIs there anybody who can figure out the problem? or know an alternative way to convert into fx graph?
Beta Was this translation helpful? Give feedback.
All reactions