Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotSupportedError error when executing Readme example "TorchScript ResNet18" #3284

Open
trirpi opened this issue May 5, 2024 · 0 comments
Open

Comments

@trirpi
Copy link

trirpi commented May 5, 2024

When executing the TorchScript ResNet18 example in the Readme, I get a NotSupportedError.

To replicate, execute:

python projects/pt1/examples/torchscript_resnet18.py

This is part of the stacktrace:

  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py", line 434, in aot_dispatch_autograd
    compiled_fw_func = aot_config.fw_compiler(fw_module, adjusted_flat_args)
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch_mlir/dynamo.py", line 139, in wrapper_backend
    user_callable = user_backend(gm, example_inputs)
  File "/home/trirpi/torch-mlir/projects/pt1/examples/torchdynamo_resnet18.py", line 78, in refbackend_torchdynamo_backend
    mlir_module = torchscript.compile(
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch_mlir/torchscript.py", line 350, in compile
    scripted = torch.jit.script(model)
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/jit/_script.py", line 1341, in script
    return torch.jit._recursive.create_script_module(
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/jit/_recursive.py", line 558, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/jit/_recursive.py", line 571, in create_script_module_impl
    method_stubs = stubs_fn(nn_module)
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/jit/_recursive.py", line 894, in infer_methods_to_compile
    stubs.append(make_stub_from_method(nn_module, method))
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/jit/_recursive.py", line 87, in make_stub_from_method
    return make_stub(func, method_name)
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/jit/_recursive.py", line 71, in make_stub
    ast = get_jit_def(func, name, self_name="RecursiveScriptModule")
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/jit/frontend.py", line 372, in get_jit_def
    return build_def(
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/jit/frontend.py", line 422, in build_def
    param_list = build_param_list(ctx, py_def.args, self_name, pdt_arg_types)
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/jit/frontend.py", line 448, in build_param_list
    raise NotSupportedError(ctx_range, _vararg_kwarg_err)
torch._dynamo.exc.BackendCompilerFailed: backend='compiler_fn' raised:
NotSupportedError: Compiled functions can't take variable number of arguments or use keyword-only arguments with defaults:
  File "/home/trirpi/venv/lib/python3.10/site-packages/torch/fx/_lazy_graph_module.py", line 112
    def _lazy_forward(self, *args, **kwargs):
                                    ~~~~~~~ <--- HERE

As mentioned in Issue #3204, this uses unowned code (make_simple_dynamo_backend). However, this example is displayed very prominently in the Readme, so I think it should be fixed or removed from the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant