diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake new file mode 100644 index 0000000000000000000000000000000000000000..45c9c7c2d68a0d98a0fd53ee0b723071746e4005 --- /dev/null +++ b/cmake/external/dirent.cmake @@ -0,0 +1,45 @@ +# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Note(chenxin33): dirent.h is only exist in Linux, so get it from github when build in windows. +# use dirent tag v1.23.2 on 09/05//2018 https://github.com/tronkko/dirent.git + +INCLUDE (ExternalProject) + +SET(DIRENT_PREFIX_DIR ${THIRD_PARTY_PATH}/dirent) +SET(DIRENT_SOURCE_DIR ${THIRD_PARTY_PATH}/dirent/src/extern_dirent) +SET(DIRENT_INCLUDE_DIR ${DIRENT_SOURCE_DIR}/include) + +include_directories(${DIRENT_INCLUDE_DIR}) + +set(DIRENT_REPOSITORY ${GIT_URL}/tronkko/dirent) +set(DIRENT_TAG 1.23.2) + +ExternalProject_Add( + extern_dirent + ${EXTERNAL_PROJECT_LOG_ARGS} + ${SHALLOW_CLONE} + GIT_REPOSITORY ${DIRENT_REPOSITORY} + GIT_TAG ${DIRENT_TAG} + PREFIX ${DIRENT_PREFIX_DIR} + UPDATE_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) + +add_library(dirent INTERFACE) + +add_dependencies(dirent extern_dirent) \ No newline at end of file diff --git a/cmake/third_party.cmake b/cmake/third_party.cmake index 7df70477682bb1f1c72ccf9214f995ae8bed07f4..8b3c17ae3dbb2be9650f8d173b0f23f6ca2f0f1d 100644 --- a/cmake/third_party.cmake +++ b/cmake/third_party.cmake @@ -378,4 +378,9 @@ if (WITH_POCKETFFT) add_definitions(-DPADDLE_WITH_POCKETFFT) endif (WITH_POCKETFFT) +if (WIN32) + include(external/dirent) + list(APPEND third_party_deps extern_dirent) +endif (WIN32) + add_custom_target(third_party ALL DEPENDS ${third_party_deps}) diff --git a/paddle/fluid/inference/tests/api/tester_helper.h b/paddle/fluid/inference/tests/api/tester_helper.h index 8e6b8b197d7f24a76401a04afa02ba4c36712e5d..01953bd721f3e3b1b988ee5ef784757c505bc888 100644 --- a/paddle/fluid/inference/tests/api/tester_helper.h +++ b/paddle/fluid/inference/tests/api/tester_helper.h @@ -465,7 +465,8 @@ void PredictionWarmUp(PaddlePredictor *predictor, } int iterations = 1; if (FLAGS_warmup_iters > 1) - iterations = std::min(FLAGS_warmup_iters, static_cast(inputs.size())); + iterations = + (std::min)(FLAGS_warmup_iters, static_cast(inputs.size())); outputs->resize(iterations); Timer warmup_timer; double elapsed_time = 0; diff --git a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_fp16_serialize_deserialize_test.cc b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_fp16_serialize_deserialize_test.cc index a5b9e6825c8d429b4825dbefd155efe4a64c8e16..7e9f71c8b3c0c95ed5f1340961d9387adcd6a3a7 100644 --- a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_fp16_serialize_deserialize_test.cc +++ b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_fp16_serialize_deserialize_test.cc @@ -13,9 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. */ #include +#ifndef _WIN32 +#include +#else // headers below are substitute of unistd.h in windows +#include +#include +#endif +#define GLOG_NO_ABBREVIATED_SEVERITIES #include #include -#include #include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h" diff --git a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.cc b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.cc index 084169da3403d842b41592ba6229441b92b41990..209dd90c480702ada5772687c8c943f611bcd03f 100644 --- a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.cc +++ b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.cc @@ -13,9 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. */ #include +#ifndef _WIN32 +#include +#else // headers below are substitute of unistd.h in windows +#include +#include +#endif +#define GLOG_NO_ABBREVIATED_SEVERITIES #include #include -#include #include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h" diff --git a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h index 86a5223cafe3cc89261f803308013d3cd1ecdb63..5ae14576dfeb027bb321c06159ed2890a0189ee3 100644 --- a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h +++ b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h @@ -14,7 +14,12 @@ limitations under the License. */ #pragma once #include #include +#ifndef _WIN32 #include +#else // headers below are substitute of unistd.h in windows +#include +#include +#endif #include #include #include diff --git a/paddle/fluid/platform/complex.h b/paddle/fluid/platform/complex.h index 065ccd375c94c00528f908b1754f036b1095530d..35de34086c57d07fd4faceb69e70c7774be0ada5 100644 --- a/paddle/fluid/platform/complex.h +++ b/paddle/fluid/platform/complex.h @@ -352,12 +352,12 @@ HOSTDEVICE inline bool operator>=(const complex& a, const complex& b) { } template -HOSTDEVICE inline complex max(const complex& a, const complex& b) { +HOSTDEVICE inline complex(max)(const complex& a, const complex& b) { return (a.real >= b.real) ? a : b; } template -HOSTDEVICE inline complex min(const complex& a, const complex& b) { +HOSTDEVICE inline complex(min)(const complex& a, const complex& b) { return (a.real < b.real) ? a : b; } @@ -507,13 +507,13 @@ struct numeric_limits> { static const bool traps = false; static const bool tinyness_before = false; - static paddle::platform::complex min() { + static paddle::platform::complex(min)() { return paddle::platform::complex(0.0, 0.0); } static paddle::platform::complex lowest() { return paddle::platform::complex(0.0, 0.0); } - static paddle::platform::complex max() { + static paddle::platform::complex(max)() { return paddle::platform::complex(0.0, 0.0); } static paddle::platform::complex epsilon() { diff --git a/paddle/fluid/platform/init.cc b/paddle/fluid/platform/init.cc index 290b3353ae54ccbad7ff549a318edb83b75fe7b8..1109ecd52824a989fefa32e81dcaeb72ef24e99a 100644 --- a/paddle/fluid/platform/init.cc +++ b/paddle/fluid/platform/init.cc @@ -37,6 +37,9 @@ limitations under the License. */ #ifdef WITH_WIN_DUMP_DBG #include #include +#ifndef NOMINMAX +#define NOMINMAX // msvc max/min macro conflict with std::min/max +#endif #include #include "DbgHelp.h" diff --git a/paddle/fluid/platform/port.h b/paddle/fluid/platform/port.h index 453bea625b0ab22bf1f5bea0c6530f40f4993752..981e5f5af644eed10c4e7612c96ba242f5c2f286 100644 --- a/paddle/fluid/platform/port.h +++ b/paddle/fluid/platform/port.h @@ -30,13 +30,16 @@ #include #include // std::accumulate #else +#ifndef NOMINMAX #define NOMINMAX // msvc max/min macro conflict with std::min/max +#endif // solve static linking error in windows // https://github.com/google/glog/issues/301 #define GOOGLE_GLOG_DLL_DECL #include // _popen, _pclose #include #include +#include #include // std::accumulate in msvc #ifndef S_ISDIR // windows port for sys/stat.h #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)