From 52607cf8f12266b9d6069f3ff4db8e5c5385f71e Mon Sep 17 00:00:00 2001 From: Ruibiao Chen Date: Tue, 5 Jul 2022 10:51:53 +0800 Subject: [PATCH] Remove header file including for boost (#44052) --- paddle/fluid/framework/feed_fetch_method.cc | 1 - paddle/fluid/framework/feed_fetch_type.h | 1 - paddle/fluid/framework/ir/cost_model.h | 1 - paddle/fluid/framework/ir/graph.h | 2 +- paddle/fluid/framework/ir/pass.h | 2 +- paddle/fluid/framework/op_version_registry.h | 1 + paddle/fluid/framework/operator.h | 2 +- paddle/fluid/framework/tuple.h | 1 - paddle/fluid/framework/type_defs.h | 2 +- paddle/fluid/inference/analysis/argument.h | 2 +- paddle/fluid/memory/stats.cc | 2 +- .../fluid/operators/controlflow/op_variant.h | 1 - .../controlflow/recurrent_op_helper.h | 2 +- .../operators/controlflow/while_op_helper.h | 1 - paddle/fluid/operators/jit/benchmark.cc | 1 - paddle/fluid/operators/jit/registry.h | 2 +- paddle/fluid/operators/math/matrix_bit_code.h | 2 +- paddle/fluid/platform/enforce.h | 2 +- paddle/fluid/platform/flags.h | 2 +- paddle/fluid/platform/monitor.h | 2 + paddle/fluid/platform/place.h | 2 +- paddle/fluid/platform/variant.h | 53 ------------------- paddle/fluid/pybind/data_set_py.cc | 2 +- paddle/fluid/pybind/fleet_wrapper_py.cc | 2 +- .../pybind/global_value_getter_setter.cc | 1 + paddle/fluid/pybind/metrics_py.cc | 2 +- paddle/fluid/pybind/nccl_wrapper_py.cc | 2 +- paddle/fluid/pybind/protobuf.h | 1 - paddle/utils/tribool.h | 25 +-------- .../custom_kernel_dot_c_setup.py | 1 - .../custom_kernel/custom_kernel_dot_setup.py | 1 - tools/prune_for_jetson.py | 2 +- 32 files changed, 22 insertions(+), 104 deletions(-) delete mode 100644 paddle/fluid/platform/variant.h diff --git a/paddle/fluid/framework/feed_fetch_method.cc b/paddle/fluid/framework/feed_fetch_method.cc index 36ab906181..47bb60810e 100644 --- a/paddle/fluid/framework/feed_fetch_method.cc +++ b/paddle/fluid/framework/feed_fetch_method.cc @@ -14,7 +14,6 @@ limitations under the License. */ #include "paddle/fluid/framework/feed_fetch_method.h" -#include #include #include "glog/logging.h" diff --git a/paddle/fluid/framework/feed_fetch_type.h b/paddle/fluid/framework/feed_fetch_type.h index 8ecd6a0339..3fe545ec9c 100644 --- a/paddle/fluid/framework/feed_fetch_type.h +++ b/paddle/fluid/framework/feed_fetch_type.h @@ -19,7 +19,6 @@ limitations under the License. */ #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/lod_tensor_array.h" #include "paddle/fluid/framework/string_array.h" -#include "paddle/fluid/platform/variant.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/ir/cost_model.h b/paddle/fluid/framework/ir/cost_model.h index 27f059a81e..558f158e84 100644 --- a/paddle/fluid/framework/ir/cost_model.h +++ b/paddle/fluid/framework/ir/cost_model.h @@ -27,7 +27,6 @@ #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/platform/profiler.h" #include "paddle/fluid/platform/profiler/event_tracing.h" -#include "paddle/fluid/platform/variant.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/ir/graph.h b/paddle/fluid/framework/ir/graph.h index ea5c46e304..5a95411077 100644 --- a/paddle/fluid/framework/ir/graph.h +++ b/paddle/fluid/framework/ir/graph.h @@ -25,7 +25,7 @@ limitations under the License. */ #include "paddle/fluid/framework/ir/node.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/utils/any.h" DECLARE_bool(convert_all_blocks); diff --git a/paddle/fluid/framework/ir/pass.h b/paddle/fluid/framework/ir/pass.h index 967482d241..37a28bec16 100644 --- a/paddle/fluid/framework/ir/pass.h +++ b/paddle/fluid/framework/ir/pass.h @@ -25,7 +25,7 @@ limitations under the License. */ #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/ir/node.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/platform/variant.h" +#include "paddle/phi/core/macros.h" #include "paddle/utils/any.h" namespace paddle { diff --git a/paddle/fluid/framework/op_version_registry.h b/paddle/fluid/framework/op_version_registry.h index c88b947edc..579dd320d1 100644 --- a/paddle/fluid/framework/op_version_registry.h +++ b/paddle/fluid/framework/op_version_registry.h @@ -22,6 +22,7 @@ limitations under the License. */ #include "paddle/fluid/framework/op_version_proto.h" #include "paddle/fluid/platform/enforce.h" +#include "paddle/phi/core/macros.h" #include "paddle/utils/none.h" namespace paddle { diff --git a/paddle/fluid/framework/operator.h b/paddle/fluid/framework/operator.h index d468ead659..1b7bd433dd 100644 --- a/paddle/fluid/framework/operator.h +++ b/paddle/fluid/framework/operator.h @@ -38,7 +38,7 @@ limitations under the License. */ #include "paddle/fluid/framework/unused_var_check.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/platform/device_context.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/phi/core/compat/arg_map_context.h" #include "paddle/phi/core/compat/op_utils.h" #include "paddle/phi/core/kernel_factory.h" diff --git a/paddle/fluid/framework/tuple.h b/paddle/fluid/framework/tuple.h index 6c283f4d32..a06f92f32d 100644 --- a/paddle/fluid/framework/tuple.h +++ b/paddle/fluid/framework/tuple.h @@ -22,7 +22,6 @@ limitations under the License. */ #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/var_desc.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/platform/variant.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/type_defs.h b/paddle/fluid/framework/type_defs.h index 5c768b10a3..3bcad63f21 100644 --- a/paddle/fluid/framework/type_defs.h +++ b/paddle/fluid/framework/type_defs.h @@ -23,7 +23,7 @@ limitations under the License. */ #include #include "paddle/fluid/imperative/type_defs.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/utils/blank.h" #include "paddle/utils/small_vector.h" #include "paddle/utils/variant.h" diff --git a/paddle/fluid/inference/analysis/argument.h b/paddle/fluid/inference/analysis/argument.h index 016df40c86..e69a1e0e1f 100644 --- a/paddle/fluid/inference/analysis/argument.h +++ b/paddle/fluid/inference/analysis/argument.h @@ -35,7 +35,7 @@ #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/inference/api/paddle_analysis_config.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/phi/common/data_type.h" namespace paddle { diff --git a/paddle/fluid/memory/stats.cc b/paddle/fluid/memory/stats.cc index 12312a28f6..0289859dff 100644 --- a/paddle/fluid/memory/stats.cc +++ b/paddle/fluid/memory/stats.cc @@ -15,7 +15,7 @@ limitations under the License. */ #include "paddle/fluid/memory/stats.h" #include "paddle/fluid/memory/allocation/spin_lock.h" -#include "paddle/fluid/platform/variant.h" +#include "paddle/phi/core/macros.h" namespace paddle { namespace memory { diff --git a/paddle/fluid/operators/controlflow/op_variant.h b/paddle/fluid/operators/controlflow/op_variant.h index c75294ce9a..04afe548e9 100644 --- a/paddle/fluid/operators/controlflow/op_variant.h +++ b/paddle/fluid/operators/controlflow/op_variant.h @@ -18,7 +18,6 @@ #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/platform/variant.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/operators/controlflow/recurrent_op_helper.h b/paddle/fluid/operators/controlflow/recurrent_op_helper.h index 78fabec56f..752a0a1f76 100644 --- a/paddle/fluid/operators/controlflow/recurrent_op_helper.h +++ b/paddle/fluid/operators/controlflow/recurrent_op_helper.h @@ -23,7 +23,7 @@ #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/operators/controlflow/op_variant.h" #include "paddle/fluid/operators/recurrent_op.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/fluid/string/string_helper.h" namespace paddle { diff --git a/paddle/fluid/operators/controlflow/while_op_helper.h b/paddle/fluid/operators/controlflow/while_op_helper.h index 46c3b056bf..8f7db23769 100644 --- a/paddle/fluid/operators/controlflow/while_op_helper.h +++ b/paddle/fluid/operators/controlflow/while_op_helper.h @@ -20,7 +20,6 @@ #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/operators/controlflow/op_variant.h" -#include "paddle/fluid/platform/variant.h" namespace phi { class DenseTensor; diff --git a/paddle/fluid/operators/jit/benchmark.cc b/paddle/fluid/operators/jit/benchmark.cc index 7ffdd6ff32..50fd6056d8 100644 --- a/paddle/fluid/operators/jit/benchmark.cc +++ b/paddle/fluid/operators/jit/benchmark.cc @@ -22,7 +22,6 @@ #include "paddle/fluid/platform/device_tracer.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/place.h" -#include "paddle/fluid/platform/variant.h" // for UNUSED DEFINE_int32(burning, 10, "Burning times."); DEFINE_int32(repeat, 3000, "Repeat times."); diff --git a/paddle/fluid/operators/jit/registry.h b/paddle/fluid/operators/jit/registry.h index b006d21f3b..9d0e47e826 100644 --- a/paddle/fluid/operators/jit/registry.h +++ b/paddle/fluid/operators/jit/registry.h @@ -22,7 +22,7 @@ #include "paddle/fluid/operators/jit/kernel_base.h" #include "paddle/fluid/operators/jit/kernel_pool.h" #include "paddle/fluid/platform/place.h" -#include "paddle/fluid/platform/variant.h" // for UNUSED +#include "paddle/phi/core/macros.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/math/matrix_bit_code.h b/paddle/fluid/operators/math/matrix_bit_code.h index 780003c1b4..7c9d94aa87 100644 --- a/paddle/fluid/operators/math/matrix_bit_code.h +++ b/paddle/fluid/operators/math/matrix_bit_code.h @@ -23,7 +23,7 @@ limitations under the License. */ #include "paddle/fluid/framework/selected_rows_utils.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/device_context.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/phi/kernels/funcs/blas/blas.h" #if defined(_WIN32) diff --git a/paddle/fluid/platform/enforce.h b/paddle/fluid/platform/enforce.h index 4f26ce0b27..6b33af9ac1 100644 --- a/paddle/fluid/platform/enforce.h +++ b/paddle/fluid/platform/enforce.h @@ -66,7 +66,7 @@ limitations under the License. */ #include "glog/logging.h" #include "paddle/fluid/platform/errors.h" #include "paddle/fluid/platform/macros.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/to_string.h" #include "paddle/phi/backends/dynload/port.h" diff --git a/paddle/fluid/platform/flags.h b/paddle/fluid/platform/flags.h index 03986816c5..6db5e710b8 100644 --- a/paddle/fluid/platform/flags.h +++ b/paddle/fluid/platform/flags.h @@ -21,7 +21,7 @@ #include "gflags/gflags.h" #include "paddle/fluid/platform/macros.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/utils/variant.h" namespace paddle { diff --git a/paddle/fluid/platform/monitor.h b/paddle/fluid/platform/monitor.h index e7612f6dcb..a0c1129d2c 100644 --- a/paddle/fluid/platform/monitor.h +++ b/paddle/fluid/platform/monitor.h @@ -26,6 +26,8 @@ #include "glog/logging.h" +#include "paddle/phi/core/macros.h" + namespace paddle { namespace platform { diff --git a/paddle/fluid/platform/place.h b/paddle/fluid/platform/place.h index d544cdecc3..cde1700771 100644 --- a/paddle/fluid/platform/place.h +++ b/paddle/fluid/platform/place.h @@ -18,7 +18,7 @@ limitations under the License. */ // #include #include "paddle/fluid/platform/enforce.h" -// #include "paddle/fluid/platform/variant.h" +// #ifdef PADDLE_WITH_ASCEND_CL #include "paddle/fluid/platform/device/npu/enforce_npu.h" #endif diff --git a/paddle/fluid/platform/variant.h b/paddle/fluid/platform/variant.h deleted file mode 100644 index 9682749898..0000000000 --- a/paddle/fluid/platform/variant.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2016 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. */ - -#pragma once - -// Boost 1.41.0 requires __CUDACC_VER__, but in CUDA 9 __CUDACC_VER__ -// is removed, so we have to manually define __CUDACC_VER__ instead. -// For details, please refer to -// https://github.com/PaddlePaddle/Paddle/issues/6626 -#if defined(__CUDACC__) && defined(__CUDACC_VER_MAJOR__) -#undef __CUDACC_VER__ -#define __CUDACC_VER__ \ - __CUDACC_VER_BUILD__ + __CUDACC_VER_MAJOR__ * 10000 + \ - __CUDACC_VER_MINOR__ * 100 -#endif - -#include "boost/config.hpp" - -// Because Boost 1.41.0's variadic templates has bug on nvcc, boost -// will disable variadic template support in NVCC mode. Define -// BOOST_NO_CXX11_VARIADIC_TEMPLATES on gcc/clang to generate same -// function symbols. For details, -// https://github.com/PaddlePaddle/Paddle/issues/3386 -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES -#define BOOST_NO_CXX11_VARIADIC_TEMPLATES -#endif -#endif - -#include -#include - -#include "paddle/utils/any.h" -#include "paddle/utils/optional.h" - -// some platform-independent defintion -#if defined(_WIN32) -#define UNUSED -#define __builtin_expect(EXP, C) (EXP) -#else -#define UNUSED __attribute__((unused)) -#endif diff --git a/paddle/fluid/pybind/data_set_py.cc b/paddle/fluid/pybind/data_set_py.cc index d5f84d7382..e1950ade92 100644 --- a/paddle/fluid/pybind/data_set_py.cc +++ b/paddle/fluid/pybind/data_set_py.cc @@ -35,7 +35,7 @@ limitations under the License. */ #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/inference/io.h" #include "paddle/fluid/platform/place.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/fluid/pybind/data_set_py.h" namespace py = pybind11; diff --git a/paddle/fluid/pybind/fleet_wrapper_py.cc b/paddle/fluid/pybind/fleet_wrapper_py.cc index 05028a9b70..8626659d86 100644 --- a/paddle/fluid/pybind/fleet_wrapper_py.cc +++ b/paddle/fluid/pybind/fleet_wrapper_py.cc @@ -33,7 +33,7 @@ limitations under the License. */ #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/inference/io.h" #include "paddle/fluid/platform/place.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/fluid/pybind/fleet_wrapper_py.h" namespace py = pybind11; diff --git a/paddle/fluid/pybind/global_value_getter_setter.cc b/paddle/fluid/pybind/global_value_getter_setter.cc index b2a52e568a..c45566ba35 100644 --- a/paddle/fluid/pybind/global_value_getter_setter.cc +++ b/paddle/fluid/pybind/global_value_getter_setter.cc @@ -27,6 +27,7 @@ #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/errors.h" #include "paddle/fluid/platform/macros.h" +#include "paddle/phi/core/macros.h" #include "pybind11/stl.h" // FIXME(zengjinle): these 2 flags may be removed by the linker when compiling diff --git a/paddle/fluid/pybind/metrics_py.cc b/paddle/fluid/pybind/metrics_py.cc index 50318cf9e6..78e6d528b1 100644 --- a/paddle/fluid/pybind/metrics_py.cc +++ b/paddle/fluid/pybind/metrics_py.cc @@ -27,7 +27,7 @@ limitations under the License. */ #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/inference/io.h" #include "paddle/fluid/platform/place.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/fluid/pybind/metrics_py.h" namespace py = pybind11; diff --git a/paddle/fluid/pybind/nccl_wrapper_py.cc b/paddle/fluid/pybind/nccl_wrapper_py.cc index bbba03f666..827bcaf397 100644 --- a/paddle/fluid/pybind/nccl_wrapper_py.cc +++ b/paddle/fluid/pybind/nccl_wrapper_py.cc @@ -33,7 +33,7 @@ limitations under the License. */ #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/inference/io.h" #include "paddle/fluid/platform/place.h" -#include "paddle/fluid/platform/variant.h" + #include "paddle/fluid/pybind/nccl_wrapper_py.h" namespace py = pybind11; diff --git a/paddle/fluid/pybind/protobuf.h b/paddle/fluid/pybind/protobuf.h index 54b788cccb..79f174b5eb 100644 --- a/paddle/fluid/pybind/protobuf.h +++ b/paddle/fluid/pybind/protobuf.h @@ -22,7 +22,6 @@ typedef SSIZE_T ssize_t; #include #include -#include "paddle/fluid/platform/variant.h" #include "pybind11/numpy.h" #include "pybind11/pybind11.h" #include "pybind11/stl.h" diff --git a/paddle/utils/tribool.h b/paddle/utils/tribool.h index 98a5019d71..9ede76f3ec 100644 --- a/paddle/utils/tribool.h +++ b/paddle/utils/tribool.h @@ -18,6 +18,7 @@ // 2. remove the depending boost header files // 3. remove the dummy_ in indeterminate_t, which is specially implemented for // Borland C++ Builder +// 4. remove unnecessary macro BOOST_TRIBOOL_THIRD_STATE // Three-state boolean logic library @@ -437,27 +438,3 @@ namespace paddle { using logic::indeterminate; using logic::tribool; } // namespace paddle - -/** - * \brief Declare a new name for the third state of a tribool - * - * Use this macro to declare a new name for the third state of a - * tribool. This state can have any number of new names (in addition - * to \c indeterminate), all of which will be equivalent. The new name will be - * placed in the namespace in which the macro is expanded. - * - * Example: - * PADDLE_TRIBOOL_THIRD_STATE(true_or_false) - * - * tribool x(true_or_false); - * // potentially set x - * if (true_or_false(x)) { - * // don't know what x is - * } - */ -#define PADDLE_TRIBOOL_THIRD_STATE(Name) \ - inline bool Name(boost::logic::tribool x, \ - boost::logic::detail::indeterminate_t dummy = \ - boost::logic::detail::indeterminate_t()) { \ - return x.value == boost::logic::tribool::indeterminate_value; \ - } diff --git a/python/paddle/fluid/tests/custom_kernel/custom_kernel_dot_c_setup.py b/python/paddle/fluid/tests/custom_kernel/custom_kernel_dot_c_setup.py index a94307161d..11fdc9d0ad 100644 --- a/python/paddle/fluid/tests/custom_kernel/custom_kernel_dot_c_setup.py +++ b/python/paddle/fluid/tests/custom_kernel/custom_kernel_dot_c_setup.py @@ -51,7 +51,6 @@ paddle_custom_kernel_include = [ compile_third_party_path = os.path.join(os.environ['PADDLE_ROOT'], 'build/third_party') paddle_custom_kernel_include += [ - os.path.join(compile_third_party_path, 'boost/src/extern_boost'), # boost os.path.join(compile_third_party_path, 'install/gflags/include'), # gflags os.path.join(compile_third_party_path, 'install/glog/include'), # glog ] diff --git a/python/paddle/fluid/tests/custom_kernel/custom_kernel_dot_setup.py b/python/paddle/fluid/tests/custom_kernel/custom_kernel_dot_setup.py index 94de1a39cc..8147fc3d34 100644 --- a/python/paddle/fluid/tests/custom_kernel/custom_kernel_dot_setup.py +++ b/python/paddle/fluid/tests/custom_kernel/custom_kernel_dot_setup.py @@ -53,7 +53,6 @@ paddle_custom_kernel_include = list( compile_third_party_path = os.path.join(os.environ['PADDLE_ROOT'], 'build/third_party') paddle_custom_kernel_include += [ - os.path.join(compile_third_party_path, 'boost/src/extern_boost'), # boost os.path.join(compile_third_party_path, 'install/gflags/include'), # gflags os.path.join(compile_third_party_path, 'install/glog/include'), # glog ] diff --git a/tools/prune_for_jetson.py b/tools/prune_for_jetson.py index d53b21d6c3..cbc0339336 100644 --- a/tools/prune_for_jetson.py +++ b/tools/prune_for_jetson.py @@ -125,7 +125,7 @@ def append_fluid_kernels(): with io.open(file_name, 'r', encoding='utf-8') as f: content = ''.join(f.readlines()) - location_str = "nv_library(\n tensorrt_op_teller\n SRCS op_teller.cc\n DEPS framework_proto device_context boost)" + location_str = "nv_library(\n tensorrt_op_teller\n SRCS op_teller.cc\n DEPS framework_proto device_context)" new_content = content.replace(location_str, location_str + append_str) if new_content == content: -- GitLab