Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented Jun 25, 2019

Stack from ghstack:

I want to get the type of self (now that everything is ultimately a
class type).

Differential Revision: D15998758

I want to get the `type` of self (now that everything is ultimately a
class type).
suo added 3 commits June 25, 2019 13:29
[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;
Copy link
Contributor

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
suo added 2 commits July 3, 2019 12:57
[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
facebook-github-bot pushed a commit that referenced this pull request Jul 9, 2019
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
@suo
Copy link
Member Author

suo commented Jul 10, 2019

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.

Copy link
Contributor

@zdevito zdevito left a 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
@zou3519 zou3519 deleted the gh/suo/71/head branch July 10, 2019 22:21
@suo suo restored the gh/suo/71/head branch July 10, 2019 23:34
@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in ee9c8a7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants