Skip to content

Respect default dtype #3798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions torch_xla/csrc/aten_xla_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ torch::lazy::BackendDevice GetXlaDeviceOrCurrent(
return xla_device_opt ? *xla_device_opt : GetCurrentDevice();
}

at::ScalarType GetScalarTypeOrFloat(c10::optional<at::ScalarType> scalar_type) {
return scalar_type ? *scalar_type : at::ScalarType::Float;
}

bool IsOperationOnType(const c10::optional<at::ScalarType>& opt_dtype,
at::ScalarType tensor_type, at::ScalarType type) {
if (opt_dtype && *opt_dtype == type) {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)));
}

Expand Down