From 6e04320246a4c72c49e1aa33c23627e110ede280 Mon Sep 17 00:00:00 2001 From: risemeup1 <62429225+risemeup1@users.noreply.github.com> Date: Mon, 22 May 2023 19:34:37 +0800 Subject: [PATCH] update_c++14_to_c++17_on_windows (#53958) * update_c++14_to_c++17_on_windows * disable test_audio_logmel_feature and test_audio_mel_feature --- cmake/flags.cmake | 2 +- paddle/fluid/framework/dlpack_tensor.cc | 5 +++-- .../memory/allocation/naive_best_fit_allocator.cc | 12 +++++++++--- paddle/fluid/operators/array_to_lod_tensor_op.cc | 4 +++- paddle/fluid/operators/lod_tensor_to_array_op.cc | 5 +++-- paddle/phi/kernels/funcs/math_function.cc | 5 +++-- paddle/utils/optional.h | 12 ++++++++---- test/legacy_test/CMakeLists.txt | 3 ++- 8 files changed, 32 insertions(+), 16 deletions(-) diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 261b5596cdd..c1dc26e101f 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -37,7 +37,7 @@ checkcompilercxx14flag() if(NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") else() - set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD 17) endif() # safe_set_flag diff --git a/paddle/fluid/framework/dlpack_tensor.cc b/paddle/fluid/framework/dlpack_tensor.cc index 6b2ab9b3b84..46b917cda74 100644 --- a/paddle/fluid/framework/dlpack_tensor.cc +++ b/paddle/fluid/framework/dlpack_tensor.cc @@ -70,8 +70,9 @@ static DLDataType GetDLDataTypeFromTypeIndex(proto::VarType::Type type) { #undef REG_DL_DATA_TYPE } -struct DLDeviceVisitor - : public std::unary_function { +struct DLDeviceVisitor { + using argument_type = const platform::Place &; + using result_type = ::DLDevice; inline ::DLDevice operator()(const platform::CPUPlace &place) const { ::DLDevice device; device.device_type = kDLCPU; diff --git a/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc b/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc index 29ac488e9c5..136f9d63a31 100644 --- a/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc +++ b/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc @@ -555,7 +555,9 @@ size_t Used(const platform::CustomPlace &place) { #endif } -struct AllocVisitor : std::unary_function { +struct AllocVisitor { + using argument_type = const Place; + using result_type = void *; inline explicit AllocVisitor(size_t size) : size_(size) {} template @@ -567,7 +569,9 @@ struct AllocVisitor : std::unary_function { size_t size_; }; -struct FreeVisitor : public std::unary_function { +struct FreeVisitor { + using argument_type = const Place; + using result_type = void; inline explicit FreeVisitor(void *ptr, size_t size) : ptr_(ptr), size_(size) {} @@ -581,7 +585,9 @@ struct FreeVisitor : public std::unary_function { size_t size_; }; -struct ReleaseVisitor : std::unary_function { +struct ReleaseVisitor { + using argument_type = const Place; + using result_type = uint64_t; template inline uint64_t operator()(const Place &place) const { return Release(place); diff --git a/paddle/fluid/operators/array_to_lod_tensor_op.cc b/paddle/fluid/operators/array_to_lod_tensor_op.cc index ebf64a92746..d1dc7d8986b 100644 --- a/paddle/fluid/operators/array_to_lod_tensor_op.cc +++ b/paddle/fluid/operators/array_to_lod_tensor_op.cc @@ -43,7 +43,9 @@ struct ArrayToLoDFunctorImpl { void apply(); }; -struct ArrayToLoDFunctor : public std::unary_function { +struct ArrayToLoDFunctor { + using argument_type = platform::Place; + using result_type = void; std::vector in; mutable phi::DenseTensor *out; diff --git a/paddle/fluid/operators/lod_tensor_to_array_op.cc b/paddle/fluid/operators/lod_tensor_to_array_op.cc index a736385a140..94b03197291 100644 --- a/paddle/fluid/operators/lod_tensor_to_array_op.cc +++ b/paddle/fluid/operators/lod_tensor_to_array_op.cc @@ -44,8 +44,9 @@ struct LoDTensorToArrayFunctorImpl { void apply(); }; -struct LoDTensorToArrayFunctor - : public std::unary_function { +struct LoDTensorToArrayFunctor { + using argument_type = platform::Place; + using result_type = void; std::vector ref_inputs_; mutable std::vector outputs_; const phi::DenseTensor &input_; diff --git a/paddle/phi/kernels/funcs/math_function.cc b/paddle/phi/kernels/funcs/math_function.cc index 2247c740114..b339a0ee5ac 100644 --- a/paddle/phi/kernels/funcs/math_function.cc +++ b/paddle/phi/kernels/funcs/math_function.cc @@ -196,8 +196,9 @@ void set_constant_with_place( phi::VisitDataType(tensor->dtype(), TensorSetConstantCPU(tensor, value)); } -struct TensorSetConstantWithPlace - : public std::unary_function { +struct TensorSetConstantWithPlace { + using argument_type = phi::Place; + using result_type = void; TensorSetConstantWithPlace(const phi::DeviceContext& context, phi::DenseTensor* tensor, float value) diff --git a/paddle/utils/optional.h b/paddle/utils/optional.h index 0b5189b70f1..3323495c9c5 100644 --- a/paddle/utils/optional.h +++ b/paddle/utils/optional.h @@ -61,8 +61,10 @@ inline bool equal_pointees(OptionalPointee const& x, OptionalPointee const& y) { } template -struct equal_pointees_t - : std::binary_function { +struct equal_pointees_t { + using first_argument_type = OptionalPointee; + using second_argument_type = OptionalPointee; + using result_type = bool; bool operator()(OptionalPointee const& x, OptionalPointee const& y) const { return equal_pointees(x, y); } @@ -83,8 +85,10 @@ inline bool less_pointees(OptionalPointee const& x, OptionalPointee const& y) { } template -struct less_pointees_t - : std::binary_function { +struct less_pointees_t { + using first_argument_type = OptionalPointee; + using second_argument_type = OptionalPointee; + using result_type = bool; bool operator()(OptionalPointee const& x, OptionalPointee const& y) const { return less_pointees(x, y); } diff --git a/test/legacy_test/CMakeLists.txt b/test/legacy_test/CMakeLists.txt index 452386f6352..8bf2f9abb98 100644 --- a/test/legacy_test/CMakeLists.txt +++ b/test/legacy_test/CMakeLists.txt @@ -19,7 +19,8 @@ if(NOT WITH_COVERAGE) endif() if(NOT WITH_GPU) - list(REMOVE_ITEM TEST_OPS test_async_read_write) + list(REMOVE_ITEM TEST_OPS test_async_read_write test_audio_logmel_feature + test_audio_mel_feature) endif() foreach(src ${TEST_OPS}) -- GitLab