diff --git a/cmake/external/gtest.cmake b/cmake/external/gtest.cmake index 114c9a816ea51b12135e3522ef625cc1e60a8f29..9b19d57136045e6e59a36e4a8ffcd12b409279f8 100644 --- a/cmake/external/gtest.cmake +++ b/cmake/external/gtest.cmake @@ -28,7 +28,7 @@ set(GTEST_INCLUDE_DIR CACHE PATH "gtest include directory." FORCE) set(GTEST_REPOSITORY ${GIT_URL}/google/googletest.git) set(GTEST_TAG release-1.8.1) - +set(GTEST_SOURCE_DIR ${THIRD_PARTY_PATH}/gtest/src/extern_gtest) include_directories(${GTEST_INCLUDE_DIR}) if(WIN32) @@ -63,7 +63,12 @@ if(WITH_MKLML) # wait for mklml downloading completed set(GTEST_DEPENDS ${MKLML_PROJECT}) endif() - +if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 12.0) + file(TO_NATIVE_PATH + ${PADDLE_SOURCE_DIR}/patches/gtest/gtest-death-test.cc.patch native_src) + set(GTEST_PATCH_COMMAND patch -d ${GTEST_SOURCE_DIR}/googletest/src < + ${native_src}) +endif() ExternalProject_Add( extern_gtest ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} diff --git a/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cpu.cc b/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cpu.cc index c8574c527fe212a50c56ead3a568209ad162c7e2..54deba9d51652c97ab03dd2d7d9d9eabf2e47db8 100644 --- a/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cpu.cc +++ b/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cpu.cc @@ -48,7 +48,7 @@ TEST(Benchmark, EagerScaleCPU) { // Prepare Device Contexts eager_test::InitEnv(paddle::platform::CPUPlace()); - for (const std::string& mode : {"Accuracy", "Performance"}) { + for (const std::string mode : {"Accuracy", "Performance"}) { paddle::framework::DDim ddim = phi::make_ddim({2, 4, 4, 4}); paddle::Tensor tensor = CreateTensorWithValue(ddim, paddle::platform::CPUPlace(), @@ -87,7 +87,7 @@ TEST(Benchmark, EagerMatmulCPU) { // Prepare Device Contexts eager_test::InitEnv(paddle::platform::CPUPlace()); - for (const std::string& mode : {"Accuracy", "Performance"}) { + for (const std::string mode : {"Accuracy", "Performance"}) { paddle::framework::DDim ddimX = phi::make_ddim({2, 2}); paddle::Tensor X = CreateTensorWithValue(ddimX, paddle::platform::CPUPlace(), @@ -137,7 +137,7 @@ TEST(Benchmark, EagerIntermediateMatmulCPU) { auto tracer = std::make_shared(); paddle::imperative::SetCurrentTracer(tracer); - for (const std::string& mode : {"Accuracy", "Performance"}) { + for (const std::string mode : {"Accuracy", "Performance"}) { paddle::framework::DDim ddimX = phi::make_ddim({2, 2}); paddle::Tensor X = CreateTensorWithValue(ddimX, paddle::platform::CPUPlace(), @@ -187,7 +187,7 @@ TEST(Benchmark, EagerIntermediateMLPCPU) { auto tracer = std::make_shared(); paddle::imperative::SetCurrentTracer(tracer); - for (const std::string& mode : {"Accuracy", "Performance"}) { + for (const std::string mode : {"Accuracy", "Performance"}) { paddle::framework::DDim ddimX = phi::make_ddim({MLP_M, MLP_N}); paddle::Tensor X = CreateTensorWithValue(ddimX, paddle::platform::CPUPlace(), diff --git a/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cpu.cc b/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cpu.cc index a76e13f6b93573e2b28035ecb82bbd74c5cb6a7c..2289a9e8680b4373581fbbe28578fd66eb19743b 100644 --- a/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cpu.cc +++ b/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cpu.cc @@ -51,7 +51,7 @@ TEST(Benchmark, FluidScaleCPU) { platform::CPUPlace place; eager_test::InitEnv(place); - for (const std::string& mode : {"Accuracy", "Performance"}) { + for (const std::string mode : {"Accuracy", "Performance"}) { std::shared_ptr X(new imperative::VarBase(true, "X")); X->SetOverridedStopGradient(false); @@ -97,7 +97,7 @@ TEST(Benchmark, FluidMatmulCPU) { platform::CPUPlace place; eager_test::InitEnv(place); - for (const std::string& mode : {"Accuracy", "Performance"}) { + for (const std::string mode : {"Accuracy", "Performance"}) { std::shared_ptr X(new imperative::VarBase(true, "X")); X->SetOverridedStopGradient(false); std::shared_ptr Y(new imperative::VarBase(true, "Y")); @@ -156,7 +156,7 @@ TEST(Benchmark, FluidMLPCPU) { platform::CPUPlace place; eager_test::InitEnv(place); - for (const std::string& mode : {"Accuracy", "Performance"}) { + for (const std::string mode : {"Accuracy", "Performance"}) { std::vector x_src_data(MLP_M * MLP_N, MLP_X_VAL); std::vector w_src_data(MLP_N * MLP_K, MLP_W_VAL); std::vector b_src_data(MLP_K, MLP_B_VAL); diff --git a/paddle/fluid/operators/pscore/distributed_lookup_table_op.h b/paddle/fluid/operators/pscore/distributed_lookup_table_op.h index c81d269f6354280d8099344273487eb8f7d4644c..d93cc993b4abc49afe3f669f20d234fed12e9c9b 100644 --- a/paddle/fluid/operators/pscore/distributed_lookup_table_op.h +++ b/paddle/fluid/operators/pscore/distributed_lookup_table_op.h @@ -119,7 +119,7 @@ class DistributedLookupTableKernel : public framework::OpKernel { auto *id_tensor = id_vars[i]->GetMutable(); auto *out_tensor = out_vars[i]->GetMutable(); - auto id_dims = id_tensor->dims(); + auto id_dims = phi::vectorize(id_tensor->dims()); out_tensor->Resize(phi::make_ddim({static_cast(id_dims[0]), static_cast(id_dims[1]), static_cast(emb_dim)})); diff --git a/paddle/fluid/platform/profiler/profiler_test.cc b/paddle/fluid/platform/profiler/profiler_test.cc index db8895576bf27507a310839b0fb7280d6f3ca65a..f7f888d9e67396b86813102e59bf405fbde55dd6 100644 --- a/paddle/fluid/platform/profiler/profiler_test.cc +++ b/paddle/fluid/platform/profiler/profiler_test.cc @@ -51,7 +51,7 @@ TEST(ProfilerTest, TestHostTracer) { auto profiler_result = profiler->Stop(); auto nodetree = profiler_result->GetNodeTrees(); std::set host_events; - for (const auto pair : nodetree->Traverse(true)) { + for (const auto& pair : nodetree->Traverse(true)) { for (const auto evt : pair.second) { host_events.insert(evt->Name()); } @@ -84,7 +84,7 @@ TEST(ProfilerTest, TestCudaTracer) { auto profiler_result = profiler->Stop(); auto nodetree = profiler_result->GetNodeTrees(); std::vector runtime_events; - for (const auto pair : nodetree->Traverse(true)) { + for (const auto& pair : nodetree->Traverse(true)) { for (const auto host_node : pair.second) { for (auto runtime_node : host_node->GetRuntimeTraceEventNodes()) { runtime_events.push_back(runtime_node->Name()); diff --git a/patches/gtest/gtest-death-test.cc.patch b/patches/gtest/gtest-death-test.cc.patch new file mode 100644 index 0000000000000000000000000000000000000000..5722bbcdc12adf0ed5149caf5a1acec77ad7bcca --- /dev/null +++ b/patches/gtest/gtest-death-test.cc.patch @@ -0,0 +1,13 @@ +diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc +index 0908355..dfcfe34 100644 +--- a/googletest/src/gtest-death-test.cc ++++ b/googletest/src/gtest-death-test.cc +@@ -1212,7 +1212,7 @@ static int ExecDeathTestChildMain(void* child_arg) { + static void StackLowerThanAddress(const void* ptr, + bool* result) GTEST_NO_INLINE_; + static void StackLowerThanAddress(const void* ptr, bool* result) { +- int dummy; ++ int dummy=0; + *result = (&dummy < ptr); + } + diff --git a/test/cpp/phi/core/test_type_info.cc b/test/cpp/phi/core/test_type_info.cc index 6d023268c7b8090363cda251c8d6b5c147d04553..56980ebbe21347493e3e738bd9477c59a492b947 100644 --- a/test/cpp/phi/core/test_type_info.cc +++ b/test/cpp/phi/core/test_type_info.cc @@ -12,6 +12,7 @@ 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. */ +#include #include "gtest/gtest.h" #include "paddle/phi/core/utils/type_registry.h"