Skip to content

Commit 28ecc10

Browse files
James Reedfacebook-github-bot
authored andcommitted
Fix WeakIValueEq (#21891)
Summary: Pull Request resolved: #21891 ghimport-source-id: a037850 Test Plan: Imported from OSS Differential Revision: D15871588 Pulled By: jamesr66a fbshipit-source-id: ecfdece1285c0737d0b1dc2afe959c43d9413001
1 parent 010f238 commit 28ecc10

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

aten/src/ATen/core/ivalue.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,11 @@ struct CAFFE2_API WeakIValue final {
495495
std::swap(tag, rhs.tag);
496496
}
497497

498+
bool isSameIdentity(const WeakIValue& rhs) const {
499+
return payload.as_int == rhs.payload.as_int && tag == rhs.tag &&
500+
is_intrusive_ptr == rhs.is_intrusive_ptr;
501+
}
502+
498503
IValue lock() const {
499504
if (!is_intrusive_ptr) {
500505
return IValue(payload, tag, false);

torch/csrc/jit/tracer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct TORCH_API TracingState
7575

7676
struct WeakIValueEq {
7777
bool operator()(const WeakIValue& t1, const WeakIValue& t2) const {
78-
return t1.lock().isSameIdentity(t2.lock());
78+
return t1.isSameIdentity(t2);
7979
}
8080
};
8181

0 commit comments

Comments
 (0)