codemod tensor.type().is_cuda(), tensor.type().is_sparse() (#13590)

Summary:
Followup to #12841

Changed these to not require type dispatch:
tensor.type().is_cuda() -> tensor.is_cuda()
tensor.type().is_sparse() -> tensor.is_sparse()
isVariable(tensor.type()) -> tensor.is_variable()

This probably does not affect performance
very much in most cases but it is nice to have.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/13590

Reviewed By: ezyang

Differential Revision: D12929301

Pulled By: zou3519

fbshipit-source-id: 8ac5c6200c579dd7a44fb4ee58fc9bb170feb1d7
This commit is contained in:
Richard Zou
2018-11-07 07:24:38 -08:00
committed by Facebook Github Bot
parent e70321ed9e
commit e60a7c2c88
23 changed files with 44 additions and 44 deletions

View File

@ -388,7 +388,7 @@ at::Type& get_default_tensor_type() {
}
Device getDevice(const at::Tensor& tensor) {
if (tensor.type().is_cuda()) {
if (tensor.is_cuda()) {
return at::Device(at::DeviceType::CUDA, tensor.get_device());
}
return at::Device(at::DeviceType::CPU);