From 02631965c85774407c8b91fe3da2fbc2dc09a39a Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Mon, 12 Nov 2018 17:29:11 +0800 Subject: [PATCH] Refine --- paddle/fluid/memory/allocation/allocator_strategy.cc | 2 ++ paddle/fluid/memory/allocation/allocator_strategy.h | 3 +++ paddle/fluid/pybind/pybind.cc | 2 ++ paddle/testing/paddle_gtest_main.cc | 2 ++ python/paddle/fluid/tests/unittests/test_data_balance.py | 2 +- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/memory/allocation/allocator_strategy.cc b/paddle/fluid/memory/allocation/allocator_strategy.cc index 3db7f4f68..b46b1e9ae 100644 --- a/paddle/fluid/memory/allocation/allocator_strategy.cc +++ b/paddle/fluid/memory/allocation/allocator_strategy.cc @@ -34,6 +34,8 @@ AllocatorStrategy GetAllocatorStrategy() { static AllocatorStrategy strategy = GetStrategyFromFlag(); return strategy; } + +void UseAllocatorStrategyGFlag() {} } // namespace allocation } // namespace memory } // namespace paddle diff --git a/paddle/fluid/memory/allocation/allocator_strategy.h b/paddle/fluid/memory/allocation/allocator_strategy.h index 0743fed3f..9adbd8799 100644 --- a/paddle/fluid/memory/allocation/allocator_strategy.h +++ b/paddle/fluid/memory/allocation/allocator_strategy.h @@ -22,6 +22,9 @@ enum class AllocatorStrategy { kLegacy, kNaiveBestFit }; extern AllocatorStrategy GetAllocatorStrategy(); +// Do nothing, just make sure linker do not prune this file. +extern void UseAllocatorStrategyGFlag(); + } // namespace allocation } // namespace memory } // namespace paddle diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index 238cc1918..806b304be 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -34,6 +34,7 @@ limitations under the License. */ #include "paddle/fluid/framework/reader.h" #include "paddle/fluid/framework/selected_rows.h" #include "paddle/fluid/framework/version.h" +#include "paddle/fluid/memory/allocation/allocator_strategy.h" #include "paddle/fluid/operators/activation_op.h" #include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h" #include "paddle/fluid/platform/enforce.h" @@ -83,6 +84,7 @@ bool IsCompiledWithDIST() { } PYBIND11_PLUGIN(core) { + paddle::memory::allocation::UseAllocatorStrategyGFlag(); py::module m("core", "C++ core of PaddlePaddle"); // using framework in this function. Since it is inside a function, it will diff --git a/paddle/testing/paddle_gtest_main.cc b/paddle/testing/paddle_gtest_main.cc index 32d433b69..598f43546 100644 --- a/paddle/testing/paddle_gtest_main.cc +++ b/paddle/testing/paddle_gtest_main.cc @@ -16,10 +16,12 @@ limitations under the License. */ #include "gflags/gflags.h" #include "gtest/gtest.h" +#include "paddle/fluid/memory/allocation/allocator_strategy.h" #include "paddle/fluid/memory/memory.h" #include "paddle/fluid/platform/init.h" int main(int argc, char** argv) { + paddle::memory::allocation::UseAllocatorStrategyGFlag(); testing::InitGoogleTest(&argc, argv); std::vector new_argv; std::string gflags_env; diff --git a/python/paddle/fluid/tests/unittests/test_data_balance.py b/python/paddle/fluid/tests/unittests/test_data_balance.py index 4bd24510b..aa19a5edc 100644 --- a/python/paddle/fluid/tests/unittests/test_data_balance.py +++ b/python/paddle/fluid/tests/unittests/test_data_balance.py @@ -116,7 +116,7 @@ class TestDataBalance(unittest.TestCase): print("WARNING: Unittest TestDataBalance skipped. \ For the result is not correct when device count \ is larger than batch size.") - exit(0) + return fetch_list = [image.name, label.name] data_appeared = [False] * self.total_ins_num -- GitLab