From ba3fe5399e4bb324312ea937fe6f3b271aec9ee6 Mon Sep 17 00:00:00 2001 From: Peter Bell Date: Fri, 29 Jul 2022 19:27:29 +0100 Subject: [PATCH 1/3] Respect default dtype Prior to the linked PR, the python API never actually passed nullopt and so the `OrFloat` path was never tested. --- torch_patches/.torch_pin | 1 + torch_xla/csrc/aten_xla_type.cpp | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) create mode 100644 torch_patches/.torch_pin diff --git a/torch_patches/.torch_pin b/torch_patches/.torch_pin new file mode 100644 index 000000000000..524507a7a99f --- /dev/null +++ b/torch_patches/.torch_pin @@ -0,0 +1 @@ +#82241 diff --git a/torch_xla/csrc/aten_xla_type.cpp b/torch_xla/csrc/aten_xla_type.cpp index 97c07c7741aa..24b7fc5dcb81 100644 --- a/torch_xla/csrc/aten_xla_type.cpp +++ b/torch_xla/csrc/aten_xla_type.cpp @@ -84,10 +84,6 @@ torch::lazy::BackendDevice GetXlaDeviceOrCurrent( return xla_device_opt ? *xla_device_opt : GetCurrentDevice(); } -at::ScalarType GetScalarTypeOrFloat(c10::optional scalar_type) { - return scalar_type ? *scalar_type : at::ScalarType::Float; -} - bool IsOperationOnType(const c10::optional& opt_dtype, at::ScalarType tensor_type, at::ScalarType type) { if (opt_dtype && *opt_dtype == type) { @@ -1310,7 +1306,7 @@ at::Tensor XLANativeFunctions::empty( // s_copy_(). return bridge::AtenFromXlaTensor(XLATensor::full( XlaHelpers::I64List(size), 0, GetXlaDeviceOrCurrent(device), - GetScalarTypeOrFloat(dtype))); + at::dtype_or_default(dtype))); } at::Tensor XLANativeFunctions::empty_symint( @@ -1719,7 +1715,7 @@ at::Tensor XLANativeFunctions::linspace(const at::Scalar& start, } return bridge::AtenFromXlaTensor( - XLATensor::linspace(start, end, steps, GetScalarTypeOrFloat(dtype), + XLATensor::linspace(start, end, steps, at::dtype_or_default(dtype), GetXlaDeviceOrCurrent(device))); } From 7628682cb342bdb2af40069caeca5f7b56bba7af Mon Sep 17 00:00:00 2001 From: Peter Bell Date: Sat, 30 Jul 2022 03:24:15 +0100 Subject: [PATCH 2/3] Trigger CI From 7e72b55ea9a61794ebf2b47e3808d4414268c1cd Mon Sep 17 00:00:00 2001 From: Peter Bell Date: Sat, 30 Jul 2022 12:07:49 +0100 Subject: [PATCH 3/3] Remove .torch_pin --- torch_patches/.torch_pin | 1 - 1 file changed, 1 deletion(-) delete mode 100644 torch_patches/.torch_pin diff --git a/torch_patches/.torch_pin b/torch_patches/.torch_pin deleted file mode 100644 index 524507a7a99f..000000000000 --- a/torch_patches/.torch_pin +++ /dev/null @@ -1 +0,0 @@ -#82241