Deprecate tensor.type() (#30281)

Summary:
Fixes https://github.com/pytorch/pytorch/issues/29161.

I looked a bit at the code changes related to this and think I have all of the use cases of `DeprecatedTypeProperties` covered in the message, but suggestions from someone with more context on this would be very much appreciated :)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30281

Differential Revision: D18830818

Pulled By: ezyang

fbshipit-source-id: 1a7fcee15354ae09e6644577e7fa33bd26acfe20
This commit is contained in:
Nathan Goldbaum
2019-12-05 10:53:32 -08:00
committed by Facebook Github Bot
parent 2171f91053
commit f531815526
53 changed files with 254 additions and 209 deletions

View File

@ -81,8 +81,8 @@ PyObject* tensor_to_numpy(const at::Tensor& tensor) {
"can't convert sparse tensor to numpy. Use Tensor.to_dense() to "
"convert to a dense tensor first.");
}
if (tensor.type().backend() != Backend::CPU) {
throw TypeError("NumPy conversion for %s is not supported", tensor.type().toString().c_str());
if (tensor.options().backend() != Backend::CPU) {
throw TypeError("NumPy conversion for %s is not supported", tensor.toString().c_str());
}
if (tensor.requires_grad()) {
throw std::runtime_error(