Use C10_DEPRECATED_MESSAGE instead of TORCH_WARN_ONCE for Tensor.data<T>() (#25319)
Summary:
Using `TORCH_WARN_ONCE` for `Tensor.data<T>()` is still causing deadlocks internally. According to Dima: "So the problem seems to be in TORCH_WARN/c10::Warning::warn which produces a warning - we setup a wrapper that sends the message back to python land. But doing so requires acquiring GIL and it somehow deadlocks. In general using TORCH_WARN in so low-level API is dangerous as there's no guarantee whether we're running under GIL or not."
In order to avoid causing accidental deadlocks in other code including external extensions, the use of `TORCH_WARN_ONCE` in `Tensor.data<T>()` is changed to `C10_DEPRECATED_MESSAGE` in this PR.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25319
Reviewed By: dzhulgakov
Differential Revision: D17094933
Pulled By: yf225
fbshipit-source-id: e29dc35187f73ca7865cfa5a9ecde708cd237c58