mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
Check tensors are defined before attempting to access their impl (#106787)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/106787 Approved by: https://github.com/albanD
This commit is contained in:
committed by
PyTorch MergeBot
parent
c91d2f5bf6
commit
256fed02e9
@ -340,14 +340,14 @@ bool isResurrectable(THPVariable* self) {
|
||||
return false;
|
||||
}
|
||||
auto const& tensor = THPVariable_Unpack(self);
|
||||
if (!tensor.defined() || tensor.use_count() <= 1) {
|
||||
return false;
|
||||
}
|
||||
// Check if this is hermetic. If it is, no resurrection.
|
||||
if (tensor.unsafeGetTensorImpl()->pyobj_slot()->check_pyobj(
|
||||
getPyInterpreter()) != c10::make_optional((PyObject*)self)) {
|
||||
return false;
|
||||
}
|
||||
if (!tensor.defined() || tensor.use_count() <= 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user