Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented Oct 22, 2019

Stack from ghstack:

Currently @property methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

Since lack of @property support is easily worked around (just make it
a method), I've opted to just explicitly error to avoid confusion. If
people want it, they can file an issue and we can look at their use
case.

This also helps us nicely clean up some parts of the ScriptModule conversion
path.

Pull Request resolved: #28395

Differential Revision: D18054946

Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

This PR fixes it so that `@property` actually behaves correctly:
1. Added `properties` as part of `ConcreteModuleType`.
2. Added a `PropertyValue` `SugaredValue` that behaves exactly like a
method but it can be used as a value.
3. `ModuleValue::attr` now checks wheter a method is a property, and
returns a `PropertyValue` if so.

This approach has the disadvantage of making `ModuleValue` more special.
But it has the advantage of not leaking the concept of properties deeper
into the type system.
@suo suo requested a review from apaszke as a code owner October 22, 2019 01:55
suo added a commit that referenced this pull request Oct 22, 2019
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

This PR fixes it so that `@property` actually behaves correctly:
1. Added `properties` as part of `ConcreteModuleType`.
2. Added a `PropertyValue` `SugaredValue` that behaves exactly like a
method but it can be used as a value.
3. `ModuleValue::attr` now checks wheter a method is a property, and
returns a `PropertyValue` if so.

This approach has the disadvantage of making `ModuleValue` more special.
But it has the advantage of not leaking the concept of properties deeper
into the type system.

ghstack-source-id: a13523d
Pull Request resolved: #28395
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Oct 22, 2019
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

This PR fixes it so that `@property` actually behaves correctly:
1. Added `properties` as part of `ConcreteModuleType`.
2. Added a `PropertyValue` `SugaredValue` that behaves exactly like a
method but it can be used as a value.
3. `ModuleValue::attr` now checks wheter a method is a property, and
returns a `PropertyValue` if so.

This approach has the disadvantage of making `ModuleValue` more special.
But it has the advantage of not leaking the concept of properties deeper
into the type system.

Differential Revision: [D18054946](https://our.internmc.facebook.com/intern/diff/D18054946)
suo added 2 commits October 23, 2019 15:43
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

This PR fixes it so that `@property` actually behaves correctly:
1. Added `properties` as part of `ConcreteModuleType`.
2. Added a `PropertyValue` `SugaredValue` that behaves exactly like a
method but it can be used as a value.
3. `ModuleValue::attr` now checks wheter a method is a property, and
returns a `PropertyValue` if so.

This approach has the disadvantage of making `ModuleValue` more special.
But it has the advantage of not leaking the concept of properties deeper
into the type system.

Differential Revision: [D18054946](https://our.internmc.facebook.com/intern/diff/D18054946)
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

This PR fixes it so that `@property` actually behaves correctly:
1. Added `properties` as part of `ConcreteModuleType`.
2. Added a `PropertyValue` `SugaredValue` that behaves exactly like a
method but it can be used as a value.
3. `ModuleValue::attr` now checks wheter a method is a property, and
returns a `PropertyValue` if so.

This approach has the disadvantage of making `ModuleValue` more special.
But it has the advantage of not leaking the concept of properties deeper
into the type system.

Differential Revision: [D18054946](https://our.internmc.facebook.com/intern/diff/D18054946)
suo added a commit that referenced this pull request Oct 24, 2019
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

Since lack of `@property` support is easily worked around (just make it
a method), I've opted to just explicitly error to avoid confusion. If
people want it, they can file an issue and we can look at their use
case.

This also helps us nicely clean up some parts of the ScriptModule conversion
path.

ghstack-source-id: d318663
Pull Request resolved: #28395
@suo suo requested a review from zdevito October 26, 2019 03:49
# original function => [(mangled overload name, overload function)]
overloads = {}

# TODO: should this be dir(type(mod))?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably?

Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

Since lack of `@property` support is easily worked around (just make it
a method), I've opted to just explicitly error to avoid confusion. If
people want it, they can file an issue and we can look at their use
case.

This also helps us nicely clean up some parts of the ScriptModule conversion
path.

Pull Request resolved: #28395

Differential Revision: [D18054946](https://our.internmc.facebook.com/intern/diff/D18054946)
suo added a commit that referenced this pull request Nov 7, 2019
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

Since lack of `@property` support is easily worked around (just make it
a method), I've opted to just explicitly error to avoid confusion. If
people want it, they can file an issue and we can look at their use
case.

This also helps us nicely clean up some parts of the ScriptModule conversion
path.

Pull Request resolved: #28395

Differential Revision: [D18054946](https://our.internmc.facebook.com/intern/diff/D18054946)
@kostmo
Copy link
Member

kostmo commented Nov 7, 2019

CircleCI build failures summary

As of commit 2fe2634:

  • 0/3 recognized as flaky
  • 2/3 broken upstream. You may want to rebase on the latest viable branch.
  • 1/3 failures introduced in this PR

Here are the reasons each build failed.


This comment was automatically generated by Dr. CI.
Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

This comment has been revised 3 time(s).

Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

Since lack of `@property` support is easily worked around (just make it
a method), I've opted to just explicitly error to avoid confusion. If
people want it, they can file an issue and we can look at their use
case.

This also helps us nicely clean up some parts of the ScriptModule conversion
path.

Pull Request resolved: #28395

Differential Revision: [D18054946](https://our.internmc.facebook.com/intern/diff/D18054946)
suo added a commit that referenced this pull request Nov 7, 2019
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

Since lack of `@property` support is easily worked around (just make it
a method), I've opted to just explicitly error to avoid confusion. If
people want it, they can file an issue and we can look at their use
case.

This also helps us nicely clean up some parts of the ScriptModule conversion
path.

Pull Request resolved: #28395

Differential Revision: [D18054946](https://our.internmc.facebook.com/intern/diff/D18054946)
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

Since lack of `@property` support is easily worked around (just make it
a method), I've opted to just explicitly error to avoid confusion. If
people want it, they can file an issue and we can look at their use
case.

This also helps us nicely clean up some parts of the ScriptModule conversion
path.

Pull Request resolved: #28395

Differential Revision: [D18054946](https://our.internmc.facebook.com/intern/diff/D18054946)
suo added a commit that referenced this pull request Nov 7, 2019
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

Since lack of `@property` support is easily worked around (just make it
a method), I've opted to just explicitly error to avoid confusion. If
people want it, they can file an issue and we can look at their use
case.

This also helps us nicely clean up some parts of the ScriptModule conversion
path.

Pull Request resolved: #28395

Differential Revision: [D18054946](https://our.internmc.facebook.com/intern/diff/D18054946)
suo added a commit that referenced this pull request Nov 7, 2019
Currently `@property` methods are broken in TorchScript because we
basically treat it as an attribute in the existing path: we'll evaluate
the method once and store that as the value forever.

Since lack of `@property` support is easily worked around (just make it
a method), I've opted to just explicitly error to avoid confusion. If
people want it, they can file an issue and we can look at their use
case.

This also helps us nicely clean up some parts of the ScriptModule conversion
path.

ghstack-source-id: 7ea6dab
Pull Request resolved: #28395
@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in 5800538.

@facebook-github-bot facebook-github-bot deleted the gh/suo/198/head branch November 10, 2019 15:16
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