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

[jit] `@ignore` methods are broken #30625

Open
driazati opened this issue Dec 2, 2019 · 3 comments
Labels
jit

Comments

@driazati
Copy link
Contributor

@driazati driazati commented Dec 2, 2019

class MyModule(nn.Module):
    def forward(self):
        pass

    @torch.jit.ignore
    def call_np(self) -> int:
        return np.random.choice(2, p=[.95,.05])

    @torch.jit.export
    def func(self):
        done = self.call_np()
        print (done)

scripted_module = torch.jit.script(MyModule())
print(scripted_module.func.graph)
scripted_module.func()

should work but outputs

Traceback (most recent call last):
  File "../test.py", line 190, in <module>
    scripted_module = torch.jit.script(MyModule())
  File "/home/davidriazati/dev/pytorch/torch/jit/__init__.py", line 1250, in script
    return torch.jit._recursive.recursive_script(obj)
  File "/home/davidriazati/dev/pytorch/torch/jit/_recursive.py", line 534, in recursive_script
    return create_script_module(nn_module, infer_methods_to_compile(nn_module))
  File "/home/davidriazati/dev/pytorch/torch/jit/_recursive.py", line 296, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, cpp_module, stubs)
  File "/home/davidriazati/dev/pytorch/torch/jit/_recursive.py", line 340, in create_script_module_impl
    create_methods_from_stubs(concrete_type, stubs)
  File "/home/davidriazati/dev/pytorch/torch/jit/_recursive.py", line 259, in create_methods_from_stubs
    concrete_type._create_methods(defs, rcbs, defaults)
RuntimeError: 

(__torch__.MyModule self, Tensor 0) -> (int 0):
Argument 0 not provided.
:
  File "../test.py", line 187
    @torch.jit.export
    def func(self):
        done = self.call_np()
               ~~~~~~~~~~~~ <--- HERE
        print (done)

cc @suo

@eellison

This comment has been minimized.

Copy link
Contributor

@eellison eellison commented Dec 2, 2019

Isn't this the same issue as #28537 ?

@eellison

This comment has been minimized.

Copy link
Contributor

@eellison eellison commented Dec 2, 2019

Closing because I think this is the same issue. reopen if you'd like.

@eellison eellison closed this Dec 2, 2019
@driazati

This comment has been minimized.

Copy link
Contributor Author

@driazati driazati commented Dec 3, 2019

Keeping open to save the test case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.