{"action":"created","issue":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/19504","repository_url":"https://api.github.com/repos/pytorch/pytorch","labels_url":"https://api.github.com/repos/pytorch/pytorch/issues/19504/labels{/name}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/19504/comments","events_url":"https://api.github.com/repos/pytorch/pytorch/issues/19504/events","html_url":"https://github.com/pytorch/pytorch/issues/19504","id":435278129,"node_id":"MDU6SXNzdWU0MzUyNzgxMjk=","number":19504,"title":"[jit] Cannot call `ScriptModule`s with attributes/parameters","user":{"login":"driazati","id":9407960,"node_id":"MDQ6VXNlcjk0MDc5NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/9407960?v=4","gravatar_id":"","url":"https://api.github.com/users/driazati","html_url":"https://github.com/driazati","followers_url":"https://api.github.com/users/driazati/followers","following_url":"https://api.github.com/users/driazati/following{/other_user}","gists_url":"https://api.github.com/users/driazati/gists{/gist_id}","starred_url":"https://api.github.com/users/driazati/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/driazati/subscriptions","organizations_url":"https://api.github.com/users/driazati/orgs","repos_url":"https://api.github.com/users/driazati/repos","events_url":"https://api.github.com/users/driazati/events{/privacy}","received_events_url":"https://api.github.com/users/driazati/received_events","type":"User","site_admin":false},"labels":[{"id":679953983,"node_id":"MDU6TGFiZWw2Nzk5NTM5ODM=","url":"https://api.github.com/repos/pytorch/pytorch/labels/jit","name":"jit","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-04-19T19:19:04Z","updated_at":"2019-04-22T16:26:13Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"```python\r\nclass Vocab(torch.jit.ScriptModule):\r\n    def __init__(self):\r\n        self.i = torch.jit.Attribute(2, int)\r\n\r\n    @torch.jit.script_method\r\n    def forward(self, x):\r\n        return x + self.i\r\n\r\nv = Vocab()\r\n\r\n@torch.jit.script\r\ndef lookup(y):\r\n    return v(y)\r\n```\r\n\r\nresults in \r\n\r\n```\r\nfor operator forward(Tensor x, int slot0) -> Tensor:\r\nargument slot0 not provided.\r\n@torch.jit.script\r\ndef lookup(y):\r\n    return v(y)\r\n           ~ <--- HERE\r\n:\r\n@torch.jit.script\r\ndef lookup(y):\r\n    return v(y)\r\n```"},"comment":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/comments/485466361","html_url":"https://github.com/pytorch/pytorch/issues/19504#issuecomment-485466361","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/19504","id":485466361,"node_id":"MDEyOklzc3VlQ29tbWVudDQ4NTQ2NjM2MQ==","user":{"login":"driazati","id":9407960,"node_id":"MDQ6VXNlcjk0MDc5NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/9407960?v=4","gravatar_id":"","url":"https://api.github.com/users/driazati","html_url":"https://github.com/driazati","followers_url":"https://api.github.com/users/driazati/followers","following_url":"https://api.github.com/users/driazati/following{/other_user}","gists_url":"https://api.github.com/users/driazati/gists{/gist_id}","starred_url":"https://api.github.com/users/driazati/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/driazati/subscriptions","organizations_url":"https://api.github.com/users/driazati/orgs","repos_url":"https://api.github.com/users/driazati/repos","events_url":"https://api.github.com/users/driazati/events{/privacy}","received_events_url":"https://api.github.com/users/driazati/received_events","type":"User","site_admin":false},"created_at":"2019-04-22T16:26:13Z","updated_at":"2019-04-22T16:26:13Z","author_association":"CONTRIBUTOR","body":"Semi-related errors:\r\n\r\n1. Explicitly calling the `forward` method\r\n```python\r\nclass Vocab(torch.jit.ScriptModule):\r\n    def __init__(self):\r\n        self.i = torch.jit.Attribute(2, int)\r\n\r\n    @torch.jit.script_method\r\n    def forward(self, x):\r\n        return x + self.i\r\n\r\nv = Vocab()\r\n\r\n@torch.jit.script\r\ndef lookup(y):\r\n    return v.forward(y)\r\n```\r\n\r\ngives \r\n\r\n```\r\nRuntimeError: \r\nattribute lookup is not defined on method:\r\n@torch.jit.script\r\ndef lookup(y):\r\n    return v.forward(y)\r\n           ~~~~~~~~~ <--- HERE\r\n```\r\n2. Calling a non-`forward` method\r\n```python\r\nclass Vocab(torch.jit.ScriptModule):\r\n    def __init__(self):\r\n        self.i = torch.jit.Attribute(2, int)\r\n\r\n    @torch.jit.script_method\r\n    def my_method(self, x):\r\n        return x + self.i\r\n\r\nv = Vocab()\r\n\r\ndef lookup(y):\r\n    return v.my_method(y)\r\n```\r\ngives\r\n```\r\nRuntimeError: \r\n expected this module to have a forward function..\r\n\r\n```\r\n"}}
{"actor":{"display_login":"driazati"}}