mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
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
19 lines
564 B
C++
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
|