From 0bde5149819e9854bca1363aa6c9f52f7db2496e Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Thu, 24 Nov 2022 00:57:17 +0000 Subject: [PATCH] Add `c10::` namespace in front of `optional` (#89605) Prep change for moving the codebase to C++17 standard Was part of https://github.com/pytorch/pytorch/pull/85969 Pull Request resolved: https://github.com/pytorch/pytorch/pull/89605 Approved by: https://github.com/weiwangmeta, https://github.com/kit1980 --- aten/src/ATen/mps/MPSGuardImpl.h | 8 ++++---- aten/src/ATen/native/ReduceOpsUtils.h | 2 +- aten/src/ATen/native/mps/operations/Distributions.mm | 2 +- aten/src/ATen/native/mps/operations/ReduceOps.mm | 2 +- aten/src/ATen/native/mps/operations/View.mm | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/aten/src/ATen/mps/MPSGuardImpl.h b/aten/src/ATen/mps/MPSGuardImpl.h index 27d32bf652e7a0..b6002497d223d6 100644 --- a/aten/src/ATen/mps/MPSGuardImpl.h +++ b/aten/src/ATen/mps/MPSGuardImpl.h @@ -109,12 +109,12 @@ struct TORCH_API MPSGuardImpl final : public c10::impl::DeviceGuardImplInterface struct OptionalMPSGuard { explicit OptionalMPSGuard() : guard_() {} - explicit OptionalMPSGuard(optional device_opt) + explicit OptionalMPSGuard(c10::optional device_opt) : guard_(device_opt) {} /// Set the current MPS device to the passed device index, if it is not /// nullopt - explicit OptionalMPSGuard(optional device_index_opt) + explicit OptionalMPSGuard(c10::optional device_index_opt) : guard_(device_index_opt) {} // Copy is not allowed @@ -144,14 +144,14 @@ struct OptionalMPSGuard { /// Returns the device that was set immediately prior to initialization of the /// guard, or nullopt if the guard is uninitialized. - optional original_device() const { + c10::optional original_device() const { return guard_.original_device(); } /// Returns the most recent device that was set using this device guard, /// either from construction, or via set_device, if the guard is initialized, /// or nullopt if the guard is uninitialized. - optional current_device() const { + c10::optional current_device() const { return guard_.current_device(); } diff --git a/aten/src/ATen/native/ReduceOpsUtils.h b/aten/src/ATen/native/ReduceOpsUtils.h index 9db9802ea788b6..2b46eb683f1c95 100644 --- a/aten/src/ATen/native/ReduceOpsUtils.h +++ b/aten/src/ATen/native/ReduceOpsUtils.h @@ -102,7 +102,7 @@ static inline void check_scalar_type_device_layout_equal(const Tensor& out, cons OPTION_TYPE_EQUALITY_CHECK(layout, out.options(), self.options()); } -static inline Tensor integer_upcast(const Tensor& self, optional dtype) { +static inline Tensor integer_upcast(const Tensor& self, c10::optional dtype) { ScalarType scalarType = self.scalar_type(); ScalarType upcast_scalarType = dtype.value_or(at::isIntegralType(scalarType, /*includeBool=*/true) ? ScalarType::Long : scalarType); return self.toType(upcast_scalarType); diff --git a/aten/src/ATen/native/mps/operations/Distributions.mm b/aten/src/ATen/native/mps/operations/Distributions.mm index 1da2457f3a37e5..99d01c6825b354 100644 --- a/aten/src/ATen/native/mps/operations/Distributions.mm +++ b/aten/src/ATen/native/mps/operations/Distributions.mm @@ -273,7 +273,7 @@ Tensor normal_mps(const Tensor& mean, const Tensor& std, c10::optional to_opt, c10::optional gen) { +Tensor& random_mps_(Tensor& self, int64_t from, c10::optional to_opt, c10::optional gen) { auto input_dtype = self.scalar_type(); int64_t to = 0; diff --git a/aten/src/ATen/native/mps/operations/ReduceOps.mm b/aten/src/ATen/native/mps/operations/ReduceOps.mm index 39680240f7f219..d905107b8ffd4f 100644 --- a/aten/src/ATen/native/mps/operations/ReduceOps.mm +++ b/aten/src/ATen/native/mps/operations/ReduceOps.mm @@ -331,7 +331,7 @@ Tensor trace_mps_out(const Tensor& self) { // Taken from ReduceOps.cpp inline ScalarType get_dtype_from_self( const Tensor& self, - const optional& dtype, + const c10::optional& dtype, bool promote_integers) { if (dtype.has_value()) { return dtype.value(); diff --git a/aten/src/ATen/native/mps/operations/View.mm b/aten/src/ATen/native/mps/operations/View.mm index 70c7d50b730f33..0e35c7b2f642d1 100644 --- a/aten/src/ATen/native/mps/operations/View.mm +++ b/aten/src/ATen/native/mps/operations/View.mm @@ -274,7 +274,7 @@ Tensor gatherViewTensor(const at::Tensor& src, at::Tensor& dst) } // namespace mps // implementation of as_strided() op -Tensor as_strided_tensorimpl_mps(const Tensor& self, IntArrayRef size, IntArrayRef stride, optional storage_offset_) +Tensor as_strided_tensorimpl_mps(const Tensor& self, IntArrayRef size, IntArrayRef stride, c10::optional storage_offset_) { auto storage_offset = storage_offset_.value_or(self.storage_offset()); auto result = detail::make_tensor(c10::TensorImpl::VIEW, Storage(self.storage()), self.key_set(), self.dtype());