From 1289292904f8072926c6c236738ac9c014fac3c7 Mon Sep 17 00:00:00 2001 From: chentianyu03 Date: Tue, 10 Aug 2021 11:26:27 +0800 Subject: [PATCH] copy boost/any.hpp to utils and replace boost::any with self defined any (#34613) * add any.hpp to utils and replace boost::any with self defined paddle::any * add copy any.hpp to custom op depends * modify any.hpp include path * remove boost from setup.py.in * add copy any.hpp to custom op depends * move any.hpp to paddle/utils/ dirs * move any.h to extension/include direction * copy utils to right directions --- cmake/inference_lib.cmake | 3 + .../extension/include/ext_op_meta_info.h | 137 +++++------ paddle/fluid/framework/CMakeLists.txt | 1 + paddle/fluid/framework/custom_operator.cc | 5 +- paddle/fluid/framework/ir/graph.h | 7 +- paddle/fluid/framework/ir/node.h | 8 +- paddle/fluid/framework/ir/pass.h | 11 +- paddle/fluid/inference/CMakeLists.txt | 1 + paddle/fluid/inference/tensorrt/engine.h | 7 +- paddle/fluid/pybind/CMakeLists.txt | 1 + paddle/utils/any.h | 232 ++++++++++++++++++ python/setup.py.in | 8 +- 12 files changed, 331 insertions(+), 90 deletions(-) create mode 100644 paddle/utils/any.h diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index 3dcf0b74f79..669875d81df 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -205,6 +205,9 @@ copy(inference_lib_dist copy(inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/fluid/platform/float16.h DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/) +copy(inference_lib_dist + SRCS ${PADDLE_SOURCE_DIR}/paddle/utils/any.h + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/) # CAPI inference library for only inference set(PADDLE_INFERENCE_C_INSTALL_DIR "${CMAKE_BINARY_DIR}/paddle_inference_c_install_dir" CACHE STRING diff --git a/paddle/fluid/extension/include/ext_op_meta_info.h b/paddle/fluid/extension/include/ext_op_meta_info.h index c400164c754..6f2528030e6 100644 --- a/paddle/fluid/extension/include/ext_op_meta_info.h +++ b/paddle/fluid/extension/include/ext_op_meta_info.h @@ -19,8 +19,7 @@ limitations under the License. */ #include #include -#include - +#include "any.h" #include "ext_dll_decl.h" // NOLINT #include "ext_exception.h" // NOLINT #include "ext_tensor.h" // NOLINT @@ -83,7 +82,7 @@ inline std::string Vec(const std::string& t_name) { using KernelFunc = std::vector (*)(const std::vector& inputs, const std::vector>& vec_inputs, - const std::vector& attrs); + const std::vector& attrs); #define PD_SPECIALIZE_ComputeCallHelper(attr_type) \ template \ @@ -92,14 +91,14 @@ using KernelFunc = typename... PreviousArgs> \ static Return Compute(const std::vector& inputs, \ const std::vector>& vec_inputs, \ - const std::vector& attrs, \ + const std::vector& attrs, \ const PreviousArgs&... pargs) { \ try { \ - attr_type arg = boost::any_cast(attrs[attr_idx]); \ + attr_type arg = paddle::any_cast(attrs[attr_idx]); \ return ComputeCallHelper::template Compute< \ in_idx, vec_in_idx, attr_idx + 1>(inputs, vec_inputs, attrs, \ pargs..., arg); \ - } catch (boost::bad_any_cast&) { \ + } catch (paddle::bad_any_cast&) { \ PD_THROW( \ "Attribute cast error in custom operator. Expected " #attr_type \ " value."); \ @@ -117,7 +116,7 @@ template struct KernelFuncImpl { static Return Compute(const std::vector& inputs, const std::vector>& vec_inputs, - const std::vector& attrs) { + const std::vector& attrs) { return ComputeCallHelper>::template Compute<0, 0, 0>( inputs, vec_inputs, attrs); } @@ -132,7 +131,7 @@ struct KernelFuncImpl { typename... PreviousArgs> static Return Compute(const std::vector& inputs, const std::vector>& vec_inputs, - const std::vector& attrs, + const std::vector& attrs, const PreviousArgs&... pargs) { const Tensor& arg = inputs[in_idx]; return ComputeCallHelper::template Compute { typename... PreviousArgs> static Return Compute(const std::vector& inputs, const std::vector>& vec_inputs, - const std::vector& attrs, + const std::vector& attrs, const PreviousArgs&... pargs) { const std::vector& arg = vec_inputs[vec_in_idx]; return ComputeCallHelper::template Compute< @@ -189,7 +188,7 @@ struct KernelFuncImpl { template static Return Compute(const std::vector& inputs, const std::vector>& vec_inputs, - const std::vector& attrs, + const std::vector& attrs, const Args&... args) { return impl_fn(args...); } @@ -205,67 +204,67 @@ struct KernelFuncImpl { using InferShapeFunc = std::vector> (*)( const std::vector>& input_shapes, const std::vector>>& vec_input_shapes, - const std::vector& attrs); - -#define PD_SPECIALIZE_InferShapeCallHelper_FOR_SHAPE(input_type) \ - template \ - struct InferShapeCallHelper { \ - template \ - static Return InferShape( \ - const std::vector>& input_shapes, \ - const std::vector>>& \ - vec_input_shapes, \ - const std::vector& attrs, const PreviousArgs&... pargs) { \ - input_type arg = input_shapes[in_idx]; \ - return InferShapeCallHelper::template InferShape< \ - in_idx + 1, vec_in_idx, attr_idx>(input_shapes, vec_input_shapes, \ - attrs, pargs..., arg); \ - } \ + const std::vector& attrs); + +#define PD_SPECIALIZE_InferShapeCallHelper_FOR_SHAPE(input_type) \ + template \ + struct InferShapeCallHelper { \ + template \ + static Return InferShape( \ + const std::vector>& input_shapes, \ + const std::vector>>& \ + vec_input_shapes, \ + const std::vector& attrs, const PreviousArgs&... pargs) { \ + input_type arg = input_shapes[in_idx]; \ + return InferShapeCallHelper::template InferShape< \ + in_idx + 1, vec_in_idx, attr_idx>(input_shapes, vec_input_shapes, \ + attrs, pargs..., arg); \ + } \ } -#define PD_SPECIALIZE_InferShapeCallHelper_FOR_SHAPES(input_type) \ - template \ - struct InferShapeCallHelper { \ - template \ - static Return InferShape( \ - const std::vector>& input_shapes, \ - const std::vector>>& \ - vec_input_shapes, \ - const std::vector& attrs, const PreviousArgs&... pargs) { \ - input_type arg = vec_input_shapes[vec_in_idx]; \ - return InferShapeCallHelper::template InferShape< \ - in_idx, vec_in_idx + 1, attr_idx>(input_shapes, vec_input_shapes, \ - attrs, pargs..., arg); \ - } \ +#define PD_SPECIALIZE_InferShapeCallHelper_FOR_SHAPES(input_type) \ + template \ + struct InferShapeCallHelper { \ + template \ + static Return InferShape( \ + const std::vector>& input_shapes, \ + const std::vector>>& \ + vec_input_shapes, \ + const std::vector& attrs, const PreviousArgs&... pargs) { \ + input_type arg = vec_input_shapes[vec_in_idx]; \ + return InferShapeCallHelper::template InferShape< \ + in_idx, vec_in_idx + 1, attr_idx>(input_shapes, vec_input_shapes, \ + attrs, pargs..., arg); \ + } \ } -#define PD_SPECIALIZE_InferShapeCallHelper_FOR_ATTR(attr_type) \ - template \ - struct InferShapeCallHelper { \ - template \ - static Return InferShape( \ - const std::vector>& input_shapes, \ - const std::vector>>& \ - vec_input_shapes, \ - const std::vector& attrs, const PreviousArgs&... pargs) { \ - try { \ - attr_type arg = boost::any_cast(attrs[attr_idx]); \ - return InferShapeCallHelper::template InferShape< \ - in_idx, vec_in_idx, attr_idx + 1>(input_shapes, vec_input_shapes, \ - attrs, pargs..., arg); \ - } catch (boost::bad_any_cast&) { \ - PD_THROW( \ - "Attribute cast error in custom operator InferShapeFn. " \ - "Expected " #attr_type \ - " value. InferShapeFn's attribute list must be exactly same as " \ - "Forward " \ - "KernelFn's attribute list except std::vector " \ - "attribute."); \ - } \ - } \ +#define PD_SPECIALIZE_InferShapeCallHelper_FOR_ATTR(attr_type) \ + template \ + struct InferShapeCallHelper { \ + template \ + static Return InferShape( \ + const std::vector>& input_shapes, \ + const std::vector>>& \ + vec_input_shapes, \ + const std::vector& attrs, const PreviousArgs&... pargs) { \ + try { \ + attr_type arg = paddle::any_cast(attrs[attr_idx]); \ + return InferShapeCallHelper::template InferShape< \ + in_idx, vec_in_idx, attr_idx + 1>(input_shapes, vec_input_shapes, \ + attrs, pargs..., arg); \ + } catch (paddle::bad_any_cast&) { \ + PD_THROW( \ + "Attribute cast error in custom operator InferShapeFn. " \ + "Expected " #attr_type \ + " value. InferShapeFn's attribute list must be exactly same as " \ + "Forward " \ + "KernelFn's attribute list except std::vector " \ + "attribute."); \ + } \ + } \ } template @@ -276,7 +275,7 @@ struct InferShapeFuncImpl { static Return InferShape( const std::vector>& input_shapes, const std::vector>>& vec_input_shapes, - const std::vector& attrs) { + const std::vector& attrs) { return InferShapeCallHelper>::template InferShape< 0, 0, 0>(input_shapes, vec_input_shapes, attrs); } @@ -314,7 +313,7 @@ struct InferShapeFuncImpl { static Return InferShape( const std::vector>& input_shapes, const std::vector>>& vec_input_shapes, - const std::vector& attrs, const Args&... args) { + const std::vector& attrs, const Args&... args) { return impl_fn(args...); } }; diff --git a/paddle/fluid/framework/CMakeLists.txt b/paddle/fluid/framework/CMakeLists.txt index 5f0649ddc69..419db670467 100644 --- a/paddle/fluid/framework/CMakeLists.txt +++ b/paddle/fluid/framework/CMakeLists.txt @@ -411,6 +411,7 @@ configure_file(commit.h.in commit.h) # to avoid exposing the path of the underlying file include_directories(${PADDLE_SOURCE_DIR}/paddle/fluid/platform) include_directories(${PADDLE_SOURCE_DIR}/paddle/fluid/extension/include) +include_directories(${PADDLE_SOURCE_DIR}/paddle/utils) if(WITH_ROCM) hip_library(custom_tensor SRCS ../extension/src/ext_tensor.cc DEPS lod_tensor memory enforce) diff --git a/paddle/fluid/framework/custom_operator.cc b/paddle/fluid/framework/custom_operator.cc index b1c5ff86d19..7fef165f373 100644 --- a/paddle/fluid/framework/custom_operator.cc +++ b/paddle/fluid/framework/custom_operator.cc @@ -34,6 +34,7 @@ limitations under the License. */ #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/dynload/dynamic_loader.h" #include "paddle/fluid/string/string_helper.h" +#include "paddle/utils/any.h" namespace paddle { namespace framework { @@ -149,7 +150,7 @@ static void RunKernelFunc(const framework::ExecutionContext& ctx, } } - std::vector custom_attrs; + std::vector custom_attrs; for (auto& attr_str : attrs) { auto attr_name_and_type = detail::ParseAttrStr(attr_str); auto attr_name = attr_name_and_type[0]; @@ -605,7 +606,7 @@ void RegisterOperatorWithMetaInfo( } } - std::vector custom_attrs; + std::vector custom_attrs; for (auto& attr_str : op_attrs) { auto attr_name_and_type = detail::ParseAttrStr(attr_str); auto attr_name = attr_name_and_type[0]; diff --git a/paddle/fluid/framework/ir/graph.h b/paddle/fluid/framework/ir/graph.h index 50c5671cb91..21e743e3587 100644 --- a/paddle/fluid/framework/ir/graph.h +++ b/paddle/fluid/framework/ir/graph.h @@ -25,6 +25,7 @@ limitations under the License. */ #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); @@ -147,8 +148,8 @@ class Graph { platform::errors::PreconditionNotMet( "%s attribute not registered for current graph.", attr_name)); try { - return *boost::any_cast(attrs_.at(attr_name)); - } catch (boost::bad_any_cast &) { + return *paddle::any_cast(attrs_.at(attr_name)); + } catch (paddle::bad_any_cast &) { PADDLE_THROW(platform::errors::InvalidArgument( "Invalid attribute type of %s, expected: %s, received: %s.", attr_name, platform::demangle(typeid(AttrType *).name()), // NOLINT @@ -426,7 +427,7 @@ class Graph { const Graph *main_graph_; // not owned. std::vector> sub_graphs_; - std::map attrs_; + std::map attrs_; std::map> attr_dels_; std::map> nodes_; std::unordered_set node_set_; diff --git a/paddle/fluid/framework/ir/node.h b/paddle/fluid/framework/ir/node.h index d0568f39ef6..54bd4376c6e 100644 --- a/paddle/fluid/framework/ir/node.h +++ b/paddle/fluid/framework/ir/node.h @@ -23,7 +23,7 @@ limitations under the License. */ #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/var_desc.h" #include "paddle/fluid/platform/macros.h" - +#include "paddle/utils/any.h" namespace paddle { namespace framework { class OpDesc; @@ -104,8 +104,8 @@ class Node { template T& Wrapper() { try { - return *boost::any_cast(wrapper_); - } catch (boost::bad_any_cast&) { + return *paddle::any_cast(wrapper_); + } catch (paddle::bad_any_cast&) { PADDLE_THROW(platform::errors::InvalidArgument( "Invalid wrapper type error, expected %s, actual %s.", typeid(T).name(), wrapper_type_.name())); @@ -277,7 +277,7 @@ class Node { Node() = delete; - boost::any wrapper_; + paddle::any wrapper_; std::function wrapper_deleter_; std::type_index wrapper_type_ = std::type_index(typeid(void)); diff --git a/paddle/fluid/framework/ir/pass.h b/paddle/fluid/framework/ir/pass.h index 8fb96bec9cb..fecdfc404e6 100644 --- a/paddle/fluid/framework/ir/pass.h +++ b/paddle/fluid/framework/ir/pass.h @@ -26,6 +26,7 @@ limitations under the License. */ #include "paddle/fluid/framework/ir/node.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/platform/variant.h" +#include "paddle/utils/any.h" namespace paddle { namespace framework { @@ -73,8 +74,8 @@ class Pass { platform::errors::InvalidArgument( "Attribute %s not registered for pass.", attr_name)); try { - return *boost::any_cast(attrs_.at(attr_name)); - } catch (boost::bad_any_cast &) { + return *paddle::any_cast(attrs_.at(attr_name)); + } catch (paddle::bad_any_cast &) { auto TypeToString = [](const std::type_info &info) -> std::string { if (std::type_index(info) == std::type_index(typeid(bool *))) { return "bool"; @@ -166,7 +167,7 @@ class Pass { // Pass doesn't take ownership. PassRegistrar should delete default_attrs void RegisterDefaultPassAttrs( - std::map default_attr_values) { + std::map default_attr_values) { for (auto const &attr_name : default_attr_values) { default_pass_attrs_.insert(attr_name.first); } @@ -180,7 +181,7 @@ class Pass { std::unordered_set required_pass_attrs_; std::unordered_set default_pass_attrs_; std::unordered_set required_graph_attrs_; - std::map attrs_; + std::map attrs_; std::map> attr_dels_; }; @@ -290,7 +291,7 @@ struct PassRegistrar : public Registrar { private: std::unordered_set required_pass_attrs_; std::unordered_set required_graph_attrs_; - std::map default_attr_values_; + std::map default_attr_values_; std::map> default_attr_dels_; }; diff --git a/paddle/fluid/inference/CMakeLists.txt b/paddle/fluid/inference/CMakeLists.txt index c002c7a10cb..6567c41ee1f 100644 --- a/paddle/fluid/inference/CMakeLists.txt +++ b/paddle/fluid/inference/CMakeLists.txt @@ -39,6 +39,7 @@ get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES) # Adapt to custom op mechanism: Include the header files related to the data type # to avoid exposing the path of the underlying file include_directories(${PADDLE_SOURCE_DIR}/paddle/fluid/platform) +include_directories(${PADDLE_SOURCE_DIR}/paddle/utils) add_subdirectory(api) diff --git a/paddle/fluid/inference/tensorrt/engine.h b/paddle/fluid/inference/tensorrt/engine.h index 38c453bde6d..3604a47a7eb 100644 --- a/paddle/fluid/inference/tensorrt/engine.h +++ b/paddle/fluid/inference/tensorrt/engine.h @@ -32,6 +32,7 @@ limitations under the License. */ #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" #include "paddle/fluid/inference/tensorrt/trt_int8_calibrator.h" #include "paddle/fluid/inference/utils/singleton.h" +#include "paddle/utils/any.h" namespace paddle { namespace framework { @@ -425,8 +426,8 @@ class TensorRTEngine { platform::errors::InvalidArgument( "Attribute %s not found in trt engine.", attr_name)); try { - return *boost::any_cast(attrs_.at(attr_name)); - } catch (boost::bad_any_cast&) { + return *paddle::any_cast(attrs_.at(attr_name)); + } catch (paddle::bad_any_cast&) { auto TypeToString = [](const std::type_info& info) -> std::string { if (std::type_index(info) == std::type_index(typeid(bool*))) { return "bool"; @@ -504,7 +505,7 @@ class TensorRTEngine { infer_ptr ihost_memory_; std::unordered_map quant_dynamic_range_; - std::unordered_map attrs_; + std::unordered_map attrs_; std::unordered_map> attr_dels_; // For dynamic shape diff --git a/paddle/fluid/pybind/CMakeLists.txt b/paddle/fluid/pybind/CMakeLists.txt index d6693e8abaa..b8774f42963 100644 --- a/paddle/fluid/pybind/CMakeLists.txt +++ b/paddle/fluid/pybind/CMakeLists.txt @@ -1,6 +1,7 @@ # Adapt to custom op mechanism: Include the header files related to the data type # to avoid exposing the path of the underlying file include_directories(${PADDLE_SOURCE_DIR}/paddle/fluid/platform) +include_directories(${PADDLE_SOURCE_DIR}/paddle/utils) set(PYBIND_DEPS pybind python proto_desc memory executor fleet_wrapper box_wrapper prune feed_fetch_method pass pass_builder parallel_executor profiler layer tracer engine scope_pool diff --git a/paddle/utils/any.h b/paddle/utils/any.h new file mode 100644 index 00000000000..ec803647c11 --- /dev/null +++ b/paddle/utils/any.h @@ -0,0 +1,232 @@ +//This file copy from boost/any.hpp and boost version: 1.41.0 +//Modified the following points: +//1. modify namespace from boost::any to paddle::any +//2. remove the depending boost header files +//3. remove/modify some macro + +// See http://www.boost.org/libs/any for Documentation. + +#ifndef PADDLE_ANY_INCLUDED +#define PADDLE_ANY_INCLUDED + +// what: variant type boost::any +// who: contributed by Kevlin Henney, +// with features contributed and bugs found by +// Ed Brey, Mark Rodgers, Peter Dimov, and James Curran +// when: July 2001 +// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95 + +#include +#include +#include + +// See boost/python/type_id.hpp +// TODO: add BOOST_TYPEID_COMPARE_BY_NAME to config.hpp +# if (defined(__GNUC__) && __GNUC__ >= 3) \ + || defined(_AIX) \ + || ( defined(__sgi) && defined(__host_mips)) \ + || (defined(__hpux) && defined(__HP_aCC)) \ + || (defined(linux) && defined(__INTEL_COMPILER) && defined(__ICC)) +# define BOOST_AUX_ANY_TYPE_ID_NAME +#include +# endif + +namespace paddle +{ + class any + { + public: // structors + + any() + : content(0) + { + } + + template + any(const ValueType & value) + : content(new holder(value)) + { + } + + any(const any & other) + : content(other.content ? other.content->clone() : 0) + { + } + + ~any() + { + delete content; + } + + public: // modifiers + + any & swap(any & rhs) + { + std::swap(content, rhs.content); + return *this; + } + + template + any & operator=(const ValueType & rhs) + { + any(rhs).swap(*this); + return *this; + } + + any & operator=(any rhs) + { + rhs.swap(*this); + return *this; + } + + public: // queries + + bool empty() const + { + return !content; + } + + const std::type_info & type() const + { + return content ? content->type() : typeid(void); + } + + public: // types (public so any_cast can be non-friend) + + class placeholder + { + public: // structors + + virtual ~placeholder() + { + } + + public: // queries + + virtual const std::type_info & type() const = 0; + + virtual placeholder * clone() const = 0; + + }; + + template + class holder : public placeholder + { + public: // structors + + holder(const ValueType & value) + : held(value) + { + } + + public: // queries + + virtual const std::type_info & type() const + { + return typeid(ValueType); + } + + virtual placeholder * clone() const + { + return new holder(held); + } + + public: // representation + + ValueType held; + + private: // intentionally left unimplemented + holder & operator=(const holder &); + }; + + public: // representation (public so any_cast can be non-friend) + + placeholder * content; + + }; + + class bad_any_cast : public std::bad_cast + { + public: + virtual const char * what() const throw() + { + return "paddle::bad_any_cast: " + "failed conversion using paddle::any_cast"; + } + }; + + template + ValueType * any_cast(any * operand) + { + return operand && +#ifdef BOOST_AUX_ANY_TYPE_ID_NAME + std::strcmp(operand->type().name(), typeid(ValueType).name()) == 0 +#else + operand->type() == typeid(ValueType) +#endif + ? &static_cast *>(operand->content)->held + : 0; + } + + template + inline const ValueType * any_cast(const any * operand) + { + return any_cast(const_cast(operand)); + } + + template + ValueType any_cast(any & operand) + { + typedef typename std::remove_reference::type nonref; + + // If 'nonref' is still reference type, it means the user has not + // specialized 'remove_reference'. + + // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro + // to generate specialization of remove_reference for your class + // See type traits library documentation for details + static_assert(!std::is_reference::value, "!std::is_reference::value"); + + nonref * result = any_cast(&operand); + if(!result) + throw bad_any_cast(); + return *result; + } + + template + inline ValueType any_cast(const any & operand) + { + typedef typename std::remove_reference::type nonref; + + // The comment in the above version of 'any_cast' explains when this + // assert is fired and what to do. + static_assert(!std::is_reference::value, "!std::is_reference::value"); + + return any_cast(const_cast(operand)); + } + + // Note: The "unsafe" versions of any_cast are not part of the + // public interface and may be removed at any time. They are + // required where we know what type is stored in the any and can't + // use typeid() comparison, e.g., when our types may travel across + // different shared libraries. + template + inline ValueType * unsafe_any_cast(any * operand) + { + return &static_cast *>(operand->content)->held; + } + + template + inline const ValueType * unsafe_any_cast(const any * operand) + { + return unsafe_any_cast(const_cast(operand)); + } +} + +// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#endif diff --git a/python/setup.py.in b/python/setup.py.in index f4535fe157d..d530f8483bc 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -395,11 +395,11 @@ def find_files(pattern, root, recursive=False): headers = ( list(find_files('*.h', '@PADDLE_SOURCE_DIR@/paddle')) + list(find_files('*.h', '@PADDLE_SOURCE_DIR@/paddle/fluid/extension/include')) + # extension - list(find_files('*', '${BOOST_INCLUDE_DIR}/boost', True)) + # boost # For paddle uew custom op, only copy data type headers from `paddle/fluid/platform` # to `extension/incude`, ['@PADDLE_SOURCE_DIR@/paddle/fluid/platform/complex.h'] + - ['@PADDLE_SOURCE_DIR@/paddle/fluid/platform/float16.h']) + ['@PADDLE_SOURCE_DIR@/paddle/fluid/platform/float16.h'] + + ['@PADDLE_SOURCE_DIR@/paddle/utils/any.h']) if '${WITH_MKLDNN}' == 'ON': headers += list(find_files('*', '${MKLDNN_INSTALL_DIR}/include')) # mkldnn @@ -446,12 +446,12 @@ class InstallHeaders(Command): elif 'third_party' not in header: # paddle headers install_dir = re.sub('@PADDLE_SOURCE_DIR@/', '', header) - if 'fluid' in install_dir: + if 'fluid' in install_dir or 'utils' in install_dir: install_dir = "paddle/extension/include/" else: # third_party install_dir = re.sub('${THIRD_PARTY_PATH}', 'third_party', header) - patterns = ['boost/src/extern_boost', 'install/mkldnn/include'] + patterns = ['install/mkldnn/include'] for pattern in patterns: install_dir = re.sub(pattern, '', install_dir) install_dir = os.path.join(self.install_dir, os.path.dirname(install_dir)) -- GitLab