mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-30 19:54:53 +08:00
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:
committed by
Facebook Github Bot
parent
e70321ed9e
commit
e60a7c2c88
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user