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

assert(isinstance(orig, torch.nn.Module)) when trace #105

Open
upupdayday opened this issue Jun 6, 2022 · 1 comment
Open

assert(isinstance(orig, torch.nn.Module)) when trace #105

upupdayday opened this issue Jun 6, 2022 · 1 comment

Comments

@upupdayday
Copy link

upupdayday commented Jun 6, 2022

When I trace model on cpu,I got the assert error
Have you met this before?

My environment version:

torch 1.3.0
torchvision 0.2.1

trace code:

trace_input = torch.randn(1, 3, self.cfg.DATASET.INPUT_SIZE, self.cfg.DATASET.INPUT_SIZE, dtype=torch.float)
ts = torch.jit.trace(model, trace_input, check_trace=False)

assert Error:

Traceback (most recent call last):
  File "test_HigherHRNet_mlu.py", line 394, in <module>
    higherhrnet = HigherHRNet(args, cfg)
  File "test_HigherHRNet_mlu.py", line 87, in __init__
    ts = torch.jit.trace(self.model, trace_input, check_trace=False)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 858, in trace
    check_tolerance, _force_outplace, _module_class)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 991, in trace_module
    module = make_module(mod, _module_class, _compilation_unit, tuple(inputs.keys()))
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 709, in make_module
    return _module_class(mod, _compilation_unit=_compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1462, in init_then_register
    original_init(self, *args, **kwargs)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1462, in init_then_register
    original_init(self, *args, **kwargs)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1733, in __init__
    self._modules[name] = make_module(submodule, TracedModule, _compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 709, in make_module
    return _module_class(mod, _compilation_unit=_compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1462, in init_then_register
    original_init(self, *args, **kwargs)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1733, in __init__
    self._modules[name] = make_module(submodule, TracedModule, _compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 709, in make_module
    return _module_class(mod, _compilation_unit=_compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1462, in init_then_register
    original_init(self, *args, **kwargs)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1733, in __init__
    self._modules[name] = make_module(submodule, TracedModule, _compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 709, in make_module
    return _module_class(mod, _compilation_unit=_compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1462, in init_then_register
    original_init(self, *args, **kwargs)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1733, in __init__
    self._modules[name] = make_module(submodule, TracedModule, _compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 709, in make_module
    return _module_class(mod, _compilation_unit=_compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1462, in init_then_register
    original_init(self, *args, **kwargs)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1733, in __init__
    self._modules[name] = make_module(submodule, TracedModule, _compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 709, in make_module
    return _module_class(mod, _compilation_unit=_compilation_unit)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1462, in init_then_register
    original_init(self, *args, **kwargs)
  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1710, in __init__
    assert(isinstance(orig, torch.nn.Module))
AssertionError
@dongdongzi
Copy link

I encountered the same problem

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

2 participants