Skip to content

Commit 6f6a919

Browse files
Revert "Make custom op alias check consistent (#164576)"
This reverts commit e438db2. Reverted #164576 on behalf of https://github.com/facebook-github-bot due to Diff reverted internally ([comment](#164467 (comment)))
1 parent 83d71df commit 6f6a919

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

torch/_library/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ def check_aliasing_constraint(name, prev, result, get_module=lambda: "???"):
341341
"""
342342
custom operators' outputs must not alias any inputs or other outputs.
343343
"""
344-
storages = {t.untyped_storage()._cdata for t in prev if isinstance(t, torch.Tensor)}
344+
storages = {id(t.untyped_storage()) for t in prev if isinstance(t, torch.Tensor)}
345345
tuple_result = result
346346
if not isinstance(result, tuple):
347347
tuple_result = (result,)
348348
for tensor in iter_tensors(tuple_result, {}):
349-
key = tensor.untyped_storage()._cdata
350-
if tensor.untyped_storage()._cdata in storages:
349+
key = id(tensor.untyped_storage())
350+
if id(tensor.untyped_storage()) in storages:
351351
raise RuntimeError(
352352
f"{name} (with implementation in {get_module()}): "
353353
f"The output of this custom operator (1) must not "

torch/csrc/autograd/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ static PyObject* any_output_is_alias_to_input_or_output(
11131113
if (!t.storage()) {
11141114
return false;
11151115
}
1116-
auto* cp = t.storage().unsafeGetStorageImpl();
1116+
auto* cp = t.storage().data_ptr().get_context();
11171117
if (cp) {
11181118
s.insert(cp);
11191119
}
@@ -1124,7 +1124,7 @@ static PyObject* any_output_is_alias_to_input_or_output(
11241124
if (!t.storage()) {
11251125
return false;
11261126
}
1127-
auto* cp = t.storage().unsafeGetStorageImpl();
1127+
auto* cp = t.storage().data_ptr().get_context();
11281128
if (!cp) {
11291129
return false;
11301130
}

0 commit comments

Comments
 (0)