Revert "Make custom op alias check consistent (#164576)"

This reverts commit e438db254602cf39ba536aed0590b4144c019ee8.

Reverted https://github.com/pytorch/pytorch/pull/164576 on behalf of https://github.com/facebook-github-bot due to Diff reverted internally ([comment](https://github.com/pytorch/pytorch/pull/164467#issuecomment-3368152304))
This commit is contained in:
PyTorch MergeBot
2025-10-04 11:42:45 +00:00
parent 83d71dfb2f
commit 6f6a919366
2 changed files with 5 additions and 5 deletions

View File

@ -341,13 +341,13 @@ def check_aliasing_constraint(name, prev, result, get_module=lambda: "???"):
"""
custom operators' outputs must not alias any inputs or other outputs.
"""
storages = {t.untyped_storage()._cdata for t in prev if isinstance(t, torch.Tensor)}
storages = {id(t.untyped_storage()) for t in prev if isinstance(t, torch.Tensor)}
tuple_result = result
if not isinstance(result, tuple):
tuple_result = (result,)
for tensor in iter_tensors(tuple_result, {}):
key = tensor.untyped_storage()._cdata
if tensor.untyped_storage()._cdata in storages:
key = id(tensor.untyped_storage())
if id(tensor.untyped_storage()) in storages:
raise RuntimeError(
f"{name} (with implementation in {get_module()}): "
f"The output of this custom operator (1) must not "