#37702 has fix @staticmethod for nn.Module, but this bugs still exist on normal class:
@torch.jit.script
class MyCell(object):
@staticmethod
def do_it(x, h):
new_h = torch.tanh(x + h)
return new_h, new_h
we get:
RuntimeError:
Tried to access nonexistent attribute or method '__add__' of type '__torch__.MyCell'. Did you forget to initialize an attribute in __init__()?:
File "test.py", line 8
@staticmethod
def do_it(x, h):
new_h = torch.tanh(x + h)
~~~~~ <--- HERE
return new_h, new_h
PyTorch version: master on commit 8556664
cc @suo
#37702 has fix
@staticmethodfornn.Module, but this bugs still exist on normal class:we get:
PyTorch version: master on commit 8556664
cc @suo