static PyObject * THPVariable_device(THPVariable* self) {
HANDLE_TH_ERRORS
- return THPDevice_New(torch::tensors::getDevice(self->cdata));
+ return THPDevice_New(self->cdata.device());
END_HANDLE_TH_ERRORS
}
if (!allow_copy && !r.isNone(2))
throw std::runtime_error(".to() does not accept copy argument");
return std::make_tuple(
- torch::tensors::getDevice(tensor),
+ tensor.device(),
tensor.type().scalarType(),
r.toBool(1),
r.toBool(2)
AT_ASSERT(default_tensor_type);
return *default_tensor_type;
}
-
-Device getDevice(const at::Tensor& tensor) {
- if (tensor.is_cuda()) {
- return at::Device(at::DeviceType::CUDA, tensor.get_device());
- }
- return at::Device(at::DeviceType::CPU);
-}
}} // namespace torch::tensors
// returned value will be a VariableType instance.
at::Type& get_default_tensor_type();
-// Gets the torch::Device object of a given at::Tensor
-c10::Device getDevice(const at::Tensor& tensor);
-
}} // namespace torch::tensors