Skip to content
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

Add WeakIValue, use in tracer. #21515

Closed
wants to merge 12 commits into from
Closed

Conversation

zdevito
Copy link
Contributor

@zdevito zdevito commented Jun 7, 2019

Stack from ghstack:

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.
wq

Differential Revision: D15719981

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.
wq
Zachary DeVito and others added 7 commits June 6, 2019 22:13
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.
wq

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.
wq

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.
wq

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.
wq

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.
wq

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.
wq

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
@@ -720,10 +726,7 @@ namespace intrusive_ptr {
namespace weak_intrusive_ptr {

inline void incref(weak_intrusive_ptr_target* self) {
auto wptr = c10::weak_intrusive_ptr<weak_intrusive_ptr_target>::reclaim(self);
Copy link
Contributor Author

@zdevito zdevito Jun 10, 2019

Choose a reason for hiding this comment

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

This change is necessary because ::reclaim would fail if intrusive_ptr_target has never been a weak ptr before. WeakIValue calls incref in the situation when we are creating a weak_ptr from a strong pointer when none has existed before. This ensures the method does what it says in its name.

@zdevito zdevito requested a review from suo June 10, 2019 23:53
Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
Copy link
Member

@suo suo left a comment

Choose a reason for hiding this comment

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

looks straightforward to me

IValue::Payload pl;
pl.as_intrusive_ptr = temp.lock().release();
temp.release();
if (!pl.as_intrusive_ptr) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we do this check before doing the ownership surgery?

Add WeakIValue, use in tracer.

In order to insert first-class calls to methods, we need to keep
ModuleObject -> Value* mappings in the tracer. To do this, this PR
creates a WeakIValue to replace WeakTensor, and changes the tracer
to use a WeakIValue -> Value* map.

gh-metadata: pytorch pytorch 21515 gh/zdevito/51/head
@zou3519 zou3519 deleted the gh/zdevito/51/head branch June 13, 2019 00:15
zdevito pushed a commit to zdevito/ATen that referenced this pull request Jun 13, 2019
Summary:
Pull Request resolved: pytorch/pytorch#21515
ghimport-source-id: 7898a68791db2b5050164ab01d6ca6991e05746d

Reviewed By: suo

Differential Revision: D15719981

Pulled By: zdevito

fbshipit-source-id: 42cf26cf6541bcdf95f1343da3b9228fe2c229da
@facebook-github-bot
Copy link
Contributor

@zdevito merged this pull request in 56f4602.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged module: internals Related to internal abstractions in c10 and ATen oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants