Files
pytorch/c10/core/Storage.cpp
Kurt Mohler 4c5e43574c Reland 2: Add PyObject preservation for UntypedStorage (#109039)
Relands #103907 after it was reverted. This PR makes the new `ignore_hermetic_tls` argument of `check_pyobj` optional to avoid causing a compilation error in torchdistx

Part of #91395

Pull Request resolved: https://github.com/pytorch/pytorch/pull/109039
Approved by: https://github.com/ezyang
2023-09-12 22:26:05 +00:00

19 lines
564 B
C++

#include <c10/core/RefcountedDeleter.h>
#include <c10/core/Storage.h>
namespace c10 {
bool isSharedStorageAlias(const Storage& storage0, const Storage& storage1) {
c10::DeleterFnPtr deleter_expected = &c10::refcounted_deleter;
c10::DeleterFnPtr deleter0 = storage0.data_ptr().get_deleter();
c10::DeleterFnPtr deleter1 = storage1.data_ptr().get_deleter();
if ((deleter0 != deleter_expected) || (deleter1 != deleter_expected)) {
return false;
}
return storage0.data_ptr().get_context() == storage1.data_ptr().get_context();
}
} // namespace c10