Revert "Fix double dispatch to Python for detach (#163671)"

This reverts commit c32118dc3e50505fd285e6e448a90883fce11535.

Reverted https://github.com/pytorch/pytorch/pull/163671 on behalf of https://github.com/izaitsevfb due to breaks export tests ([comment](https://github.com/pytorch/pytorch/pull/163671#issuecomment-3379281422))
This commit is contained in:
PyTorch MergeBot
2025-10-08 01:46:43 +00:00
parent c813617c53
commit 97463d4cf3
10 changed files with 90 additions and 49 deletions

View File

@ -4926,6 +4926,7 @@ Running aten.expand.default from within SumBackward0
Running aten.div.Tensor from within DivBackward0
Running aten.mul.Tensor from within MulBackward0
Running aten.detach.default from within AccumulateGrad
Running aten.detach.default from within AccumulateGrad
Done""",
)
@ -7198,7 +7199,9 @@ for shape in [(1,), ()]:
lambda x: x.exp(), x, use_reentrant=False, context_fn=context_fn
)
out.backward()
self.assertEqual(verbose_mode.operators, ["exp.default", "detach.default"])
self.assertEqual(
verbose_mode.operators, ["exp.default", "detach.default", "detach.default"]
)
with self.assertRaisesRegex(
Exception, "only supported when use_reentrant=False"