Skip to content

[jit] RuntimeError: v->type()->isSubtypeOf(elem_type) #20500

@TheCodez

Description

@TheCodez

🐛 Bug

To Reproduce

This code:

class MyMod2(torch.jit.ScriptModule):
    __constants__ = ['mean', 'std']
    def __init__(self):
        super(MyMod2, self).__init__()

        self.mean = [0.485, 0.456, 0.406]
        self.std = [0.229, 0.224, 0.225]

    @torch.jit.script_method
    def forward(self, input):
        mean = torch.tensor(self.mean)
        std = torch.tensor(self.std)
        return input.sub(mean[:, None, None]).div_(std[:, None, None])

yields the following error:

Traceback (most recent call last):
  File "C:/Development/_PytorchDev/pytorch-box2pix/jit.py", line 75, in <module>
    test = MyMod2()
  File "C:\Python36\lib\site-packages\torch\jit\__init__.py", line 1047, in init_then_register
    _create_methods_from_stubs(self, methods)
  File "C:\Python36\lib\site-packages\torch\jit\__init__.py", line 1012, in _create_methods_from_stubs
    self._c._create_methods(self, defs, rcbs, defaults)
RuntimeError: v->type()->isSubtypeOf(elem_type) ASSERT FAILED at ..\torch\csrc\jit\ir.cpp:1272, please report a bug to PyTorch. (createList at ..\torch\csrc\jit\ir.cpp:1272)
(no backtrace available)

Expected behavior

Should work without a problem.

Environment

  • PyTorch Version: 1.1.0

cc @ezyang @gchanan @zou3519 @suo

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions