-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Conversation
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
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); |
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 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.
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
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.
looks straightforward to me
IValue::Payload pl; | ||
pl.as_intrusive_ptr = temp.lock().release(); | ||
temp.release(); | ||
if (!pl.as_intrusive_ptr) { |
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.
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
Summary: Pull Request resolved: pytorch/pytorch#21515 ghimport-source-id: 7898a68791db2b5050164ab01d6ca6991e05746d Reviewed By: suo Differential Revision: D15719981 Pulled By: zdevito fbshipit-source-id: 42cf26cf6541bcdf95f1343da3b9228fe2c229da
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