Created
January 29, 2020 18:03
-
-
Save wanchaol/69db3b745aba300345fd5e584cab9016 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
@torch.jit.script | |
class MyClass(object): | |
def my_method(self): | |
# type: () -> Tensor | |
return torch.randn(10) | |
@torch.jit.ignore | |
def mod_init(): | |
return MyClass() | |
@torch.jit.script | |
def test_script_mod(): | |
# type: () -> Tensor | |
res = mod_init() | |
return res.my_method() | |
======== | |
RuntimeError: | |
Tried to access nonexistent attribute or method 'my_method' of type 'Tensor'.: | |
File "/home/wanchaol/test_script.py", line 34 | |
# type: () -> Tensor | |
res = mod_init() | |
return res.my_method() | |
~~~~~~~~~~~~~ <--- HERE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment