From e2d47a133b928c1b11ae970ced760810bcd4bda4 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Tue, 17 Dec 2024 09:22:47 +0000 Subject: [PATCH] Disable c10::optional macros (#138912) Test Plan: Sandcastle Pull Request resolved: https://github.com/pytorch/pytorch/pull/138912 Approved by: https://github.com/Skylion007, https://github.com/malfet --- aten/src/ATen/native/mkldnn/xpu/detail/QConv.cpp | 2 +- aten/src/ATen/native/mkldnn/xpu/qconv.cpp | 6 +++--- c10/util/Optional.h | 3 +++ torch/csrc/api/include/torch/types.h | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/aten/src/ATen/native/mkldnn/xpu/detail/QConv.cpp b/aten/src/ATen/native/mkldnn/xpu/detail/QConv.cpp index e60d43422f0..99090229e26 100644 --- a/aten/src/ATen/native/mkldnn/xpu/detail/QConv.cpp +++ b/aten/src/ATen/native/mkldnn/xpu/detail/QConv.cpp @@ -194,7 +194,7 @@ at::Tensor quantized_convolution( Tensor scratchpad_tensor = at::empty( {static_cast(scratchpad_size)}, act.options().dtype(at::kByte), - c10::nullopt); + std::nullopt); auto scratchpad_m = make_onednn_memory( conv_fwd_pd.scratchpad_desc(), engine, scratchpad_tensor.data_ptr()); args.insert({DNNL_ARG_SCRATCHPAD, scratchpad_m}); diff --git a/aten/src/ATen/native/mkldnn/xpu/qconv.cpp b/aten/src/ATen/native/mkldnn/xpu/qconv.cpp index e641bcd547d..5354652138b 100644 --- a/aten/src/ATen/native/mkldnn/xpu/qconv.cpp +++ b/aten/src/ATen/native/mkldnn/xpu/qconv.cpp @@ -94,12 +94,12 @@ class QConvoneDNNXPU final { output, inv_output_scale, output_zero_point, - /*accum*/ c10::nullopt, + /*accum*/ std::nullopt, /*accum_scale*/ 0.0, /*accum_zero_point*/ 0, /*output_dtype*/ output_dtype, - /*binary_attr*/ c10::nullopt, - /*binary_alpha*/ c10::nullopt, + /*binary_attr*/ std::nullopt, + /*binary_alpha*/ std::nullopt, /*unary_attr*/ attr, /*unary_scalars*/ scalars, /*unary_algorithm*/ algorithm); diff --git a/c10/util/Optional.h b/c10/util/Optional.h index cbb3a5abb47..d9a551ed198 100644 --- a/c10/util/Optional.h +++ b/c10/util/Optional.h @@ -9,6 +9,8 @@ // up builds. namespace c10 { + +#if !defined(FBCODE_CAFFE2) && !defined(C10_NODEPRECATED) // NOLINTNEXTLINE(misc-unused-using-decls) using std::bad_optional_access; // NOLINTNEXTLINE(misc-unused-using-decls) @@ -19,6 +21,7 @@ using std::nullopt; using std::nullopt_t; // NOLINTNEXTLINE(misc-unused-using-decls) using std::optional; +#endif #if !defined(FBCODE_CAFFE2) && !defined(C10_NODEPRECATED) diff --git a/torch/csrc/api/include/torch/types.h b/torch/csrc/api/include/torch/types.h index 3e9d0166071..0adf8f4f63c 100644 --- a/torch/csrc/api/include/torch/types.h +++ b/torch/csrc/api/include/torch/types.h @@ -38,8 +38,10 @@ namespace torch { // the `func()` function defined in `at::` namespace is always hidden. using namespace at; // NOLINT +#if !defined(FBCODE_CAFFE2) && !defined(C10_NODEPRECATED) using std::nullopt; // NOLINT using std::optional; // NOLINT +#endif using Dtype = at::ScalarType;