Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented May 3, 2019

Stack from ghstack:

It turns out that methods are reported in Python in name order instead
of definition order. This means that potentially we can try to compile a
method before init, which will break if we wanted to use any
attributes that get defined in init.

This PR fixes that by special-casing init so that its always
compiled first. Fixes #20004.

Differential Revision: D15197079

It turns out that methods are reported in Python in name order instead
of definition order. This means that potentially we can try to compile a
method before __init__, which will break if we wanted to use any
attributes that get defined in __init__.

This PR fixes that by special-casing __init__ so that its always
compiled first. Fixes #20004.
@pytorchbot pytorchbot added the oncall: jit Add this issue/PR to JIT oncall triage queue label May 3, 2019
[jit] fix compilation order for class methods

It turns out that methods are reported in Python in name order instead
of definition order. This means that potentially we can try to compile a
method before __init__, which will break if we wanted to use any
attributes that get defined in __init__.

This PR fixes that by special-casing __init__ so that its always
compiled first. Fixes #20004.

gh-metadata: pytorch pytorch 20094 gh/suo/34/head
@driazati
Copy link
Contributor

driazati commented May 3, 2019

Does this mean that calling methods from within __init__ is not supported?

@suo
Copy link
Member Author

suo commented May 3, 2019

Does this mean that calling methods from within init is not supported?

No, that's fine, we lazily compile class methods (see ensure_defined()). It's only an issue for class types, because of the way we use __init__ to determine what slots a class has.

[jit] fix compilation order for class methods

It turns out that methods are reported in Python in name order instead
of definition order. This means that potentially we can try to compile a
method before __init__, which will break if we wanted to use any
attributes that get defined in __init__.

This PR fixes that by special-casing __init__ so that its always
compiled first. Fixes #20004.

gh-metadata: pytorch pytorch 20094 gh/suo/34/head
@zou3519 zou3519 deleted the gh/suo/34/head branch May 6, 2019 22:27
@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in e37d9c8.

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.

7 participants