diff --git a/paddle/fluid/memory/allocation/allocator_strategy.cc b/paddle/fluid/memory/allocation/allocator_strategy.cc index 3db7f4f683e95b604199f34539229dd46b790404..b46b1e9ae206b82f5810b4ba7345ebc60fb84285 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 0743fed3f001230adb24d407d8892fab5d8fc6f2..9adbd879939c562cf84579a92f21d3b82e69a7e5 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 238cc19189cfd74afa38bdcb5f5c802f9521dfea..806b304be593463690063e9d454083ed7fc88b98 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 32d433b698566b7cfafe83937afc8118a3c0c527..598f435461b40ed07e97c0adde79dc1014b60a2e 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 4bd24510bc8ac7f0fbaad3fd1919ab589cd21c4b..aa19a5edc7814315edaacf6e76072f62fcf7eb55 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