-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] refactor self to be a class again #22207
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
Conversation
I want to get the `type` of self (now that everything is ultimately a class type).
[jit] refactor self to be a class again I want to get the `type` of self (now that everything is ultimately a class type). gh-metadata: pytorch pytorch 22207 gh/suo/71/head
[jit] refactor self to be a class again I want to get the `type` of self (now that everything is ultimately a class type). gh-metadata: pytorch pytorch 22207 gh/suo/71/head
[jit] refactor self to be a class again I want to get the `type` of self (now that everything is ultimately a class type). gh-metadata: pytorch pytorch 22207 gh/suo/71/head
| struct Self { | ||
| virtual ~Self() {} | ||
| virtual std::shared_ptr<SugaredValue> makeSugared(Value* v) const = 0; | ||
| virtual ClassTypePtr getClassType() const = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused in the PR, which makes it hard for me to evaluate this PR on its own. I don't like having to do this because it re-introduces an annoying complexity for this self argument. I don't understand why we can't extract the type for the value (v->type()) or from the schema.
[jit] refactor self to be a class again I want to get the `type` of self (now that everything is ultimately a class type). gh-metadata: pytorch pytorch 22207 gh/suo/71/head
[jit] refactor self to be a class again I want to get the `type` of self (now that everything is ultimately a class type). gh-metadata: pytorch pytorch 22207 gh/suo/71/head
[jit] refactor self to be a class again I want to get the `type` of self (now that everything is ultimately a class type). gh-metadata: pytorch pytorch 22207 gh/suo/71/head
Summary:
The error for `test_error_stack_module`:
```
Traceback (most recent call last):
File "../test.py", line 35, in <module>
scripted = torch.jit.script(M())
File "/home/davidriazati/other/pytorch/torch/jit/__init__.py", line 1119, in script
return _convert_to_script_module(obj)
File "/home/davidriazati/other/pytorch/torch/jit/__init__.py", line 1825, in _convert_to_script_module
raise e
RuntimeError:
d(int x) -> int:
Expected a value of type 'int' for argument 'x' but instead found type 'str'.
:
at ../test.py:11:12
def c(x):
return d("hello") + d(x)
~ <--- HERE
'c' is being compiled since it was called from 'b'
at ../test.py:14:12
def b(x):
return c(x)
~~~ <--- HERE
'b' is being compiled since it was called from 'forward'
at ../test.py:22:16
def forward(self, x):
return b(x)
~~~ <--- HERE
'forward' is being compiled since it was called from 'forward'
at ../test.py:31:20
def forward(self, x):
return x + self.submodule(x)
~~~~~~~~~~~~~~~~ <--- HERE
```
This also unifies our error reporting in the front end with `ErrorReport`
TODO
* Include module names in message, #22207 should make this easy
](https://our.intern.facebook.com/intern/diff/16060781/)
Pull Request resolved: #22280
Pulled By: driazati
Differential Revision: D16060781
fbshipit-source-id: c42968b53aaddb774ac69d5abbf7e60c23df8eed
[jit] refactor self to be a class again I want to get the `type` of self (now that everything is ultimately a class type). gh-metadata: pytorch pytorch 22207 gh/suo/71/head
|
Re-requesting review. I mentioned on the above PR: we need to be able to register the fact that the method exists before compiling it, so that methods can find each other. |
zdevito
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be clearer as a separate method, but my opinion here is not very strong.
[jit] refactor self to be a class again I want to get the `type` of self (now that everything is ultimately a class type). gh-metadata: pytorch pytorch 22207 gh/suo/71/head
Stack from ghstack:
I want to get the
typeof self (now that everything is ultimately aclass type).
Differential Revision: D15998758