未验证 提交 12892929 编写于 作者: C chentianyu03 提交者: GitHub

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
上级 d86c26dc
......@@ -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
......
......@@ -19,8 +19,7 @@ limitations under the License. */
#include <unordered_map>
#include <vector>
#include <boost/any.hpp>
#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<Tensor> (*)(const std::vector<Tensor>& inputs,
const std::vector<std::vector<Tensor>>& vec_inputs,
const std::vector<boost::any>& attrs);
const std::vector<paddle::any>& attrs);
#define PD_SPECIALIZE_ComputeCallHelper(attr_type) \
template <typename... Tail> \
......@@ -92,14 +91,14 @@ using KernelFunc =
typename... PreviousArgs> \
static Return Compute(const std::vector<Tensor>& inputs, \
const std::vector<std::vector<Tensor>>& vec_inputs, \
const std::vector<boost::any>& attrs, \
const std::vector<paddle::any>& attrs, \
const PreviousArgs&... pargs) { \
try { \
attr_type arg = boost::any_cast<attr_type>(attrs[attr_idx]); \
attr_type arg = paddle::any_cast<attr_type>(attrs[attr_idx]); \
return ComputeCallHelper<Tail...>::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 <typename Return, typename... Args, Return (*impl_fn)(Args...)>
struct KernelFuncImpl<Return (*)(Args...), impl_fn> {
static Return Compute(const std::vector<Tensor>& inputs,
const std::vector<std::vector<Tensor>>& vec_inputs,
const std::vector<boost::any>& attrs) {
const std::vector<paddle::any>& attrs) {
return ComputeCallHelper<Args..., TypeTag<int>>::template Compute<0, 0, 0>(
inputs, vec_inputs, attrs);
}
......@@ -132,7 +131,7 @@ struct KernelFuncImpl<Return (*)(Args...), impl_fn> {
typename... PreviousArgs>
static Return Compute(const std::vector<Tensor>& inputs,
const std::vector<std::vector<Tensor>>& vec_inputs,
const std::vector<boost::any>& attrs,
const std::vector<paddle::any>& attrs,
const PreviousArgs&... pargs) {
const Tensor& arg = inputs[in_idx];
return ComputeCallHelper<Tail...>::template Compute<in_idx + 1,
......@@ -147,7 +146,7 @@ struct KernelFuncImpl<Return (*)(Args...), impl_fn> {
typename... PreviousArgs>
static Return Compute(const std::vector<Tensor>& inputs,
const std::vector<std::vector<Tensor>>& vec_inputs,
const std::vector<boost::any>& attrs,
const std::vector<paddle::any>& attrs,
const PreviousArgs&... pargs) {
const std::vector<Tensor>& arg = vec_inputs[vec_in_idx];
return ComputeCallHelper<Tail...>::template Compute<
......@@ -189,7 +188,7 @@ struct KernelFuncImpl<Return (*)(Args...), impl_fn> {
template <int in_idx, int vec_in_idx, int attr_idx>
static Return Compute(const std::vector<Tensor>& inputs,
const std::vector<std::vector<Tensor>>& vec_inputs,
const std::vector<boost::any>& attrs,
const std::vector<paddle::any>& attrs,
const Args&... args) {
return impl_fn(args...);
}
......@@ -205,67 +204,67 @@ struct KernelFuncImpl<Return (*)(Args...), impl_fn> {
using InferShapeFunc = std::vector<std::vector<int64_t>> (*)(
const std::vector<std::vector<int64_t>>& input_shapes,
const std::vector<std::vector<std::vector<int64_t>>>& vec_input_shapes,
const std::vector<boost::any>& attrs);
#define PD_SPECIALIZE_InferShapeCallHelper_FOR_SHAPE(input_type) \
template <typename... Tail> \
struct InferShapeCallHelper<input_type, Tail...> { \
template <int in_idx, int vec_in_idx, int attr_idx, \
typename... PreviousArgs> \
static Return InferShape( \
const std::vector<std::vector<int64_t>>& input_shapes, \
const std::vector<std::vector<std::vector<int64_t>>>& \
vec_input_shapes, \
const std::vector<boost::any>& attrs, const PreviousArgs&... pargs) { \
input_type arg = input_shapes[in_idx]; \
return InferShapeCallHelper<Tail...>::template InferShape< \
in_idx + 1, vec_in_idx, attr_idx>(input_shapes, vec_input_shapes, \
attrs, pargs..., arg); \
} \
const std::vector<paddle::any>& attrs);
#define PD_SPECIALIZE_InferShapeCallHelper_FOR_SHAPE(input_type) \
template <typename... Tail> \
struct InferShapeCallHelper<input_type, Tail...> { \
template <int in_idx, int vec_in_idx, int attr_idx, \
typename... PreviousArgs> \
static Return InferShape( \
const std::vector<std::vector<int64_t>>& input_shapes, \
const std::vector<std::vector<std::vector<int64_t>>>& \
vec_input_shapes, \
const std::vector<paddle::any>& attrs, const PreviousArgs&... pargs) { \
input_type arg = input_shapes[in_idx]; \
return InferShapeCallHelper<Tail...>::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 <typename... Tail> \
struct InferShapeCallHelper<input_type, Tail...> { \
template <int in_idx, int vec_in_idx, int attr_idx, \
typename... PreviousArgs> \
static Return InferShape( \
const std::vector<std::vector<int64_t>>& input_shapes, \
const std::vector<std::vector<std::vector<int64_t>>>& \
vec_input_shapes, \
const std::vector<boost::any>& attrs, const PreviousArgs&... pargs) { \
input_type arg = vec_input_shapes[vec_in_idx]; \
return InferShapeCallHelper<Tail...>::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 <typename... Tail> \
struct InferShapeCallHelper<input_type, Tail...> { \
template <int in_idx, int vec_in_idx, int attr_idx, \
typename... PreviousArgs> \
static Return InferShape( \
const std::vector<std::vector<int64_t>>& input_shapes, \
const std::vector<std::vector<std::vector<int64_t>>>& \
vec_input_shapes, \
const std::vector<paddle::any>& attrs, const PreviousArgs&... pargs) { \
input_type arg = vec_input_shapes[vec_in_idx]; \
return InferShapeCallHelper<Tail...>::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 <typename... Tail> \
struct InferShapeCallHelper<attr_type, Tail...> { \
template <int in_idx, int vec_in_idx, int attr_idx, \
typename... PreviousArgs> \
static Return InferShape( \
const std::vector<std::vector<int64_t>>& input_shapes, \
const std::vector<std::vector<std::vector<int64_t>>>& \
vec_input_shapes, \
const std::vector<boost::any>& attrs, const PreviousArgs&... pargs) { \
try { \
attr_type arg = boost::any_cast<attr_type>(attrs[attr_idx]); \
return InferShapeCallHelper<Tail...>::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<int64_t> " \
"attribute."); \
} \
} \
#define PD_SPECIALIZE_InferShapeCallHelper_FOR_ATTR(attr_type) \
template <typename... Tail> \
struct InferShapeCallHelper<attr_type, Tail...> { \
template <int in_idx, int vec_in_idx, int attr_idx, \
typename... PreviousArgs> \
static Return InferShape( \
const std::vector<std::vector<int64_t>>& input_shapes, \
const std::vector<std::vector<std::vector<int64_t>>>& \
vec_input_shapes, \
const std::vector<paddle::any>& attrs, const PreviousArgs&... pargs) { \
try { \
attr_type arg = paddle::any_cast<attr_type>(attrs[attr_idx]); \
return InferShapeCallHelper<Tail...>::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<int64_t> " \
"attribute."); \
} \
} \
}
template <typename F, F f>
......@@ -276,7 +275,7 @@ struct InferShapeFuncImpl<Return (*)(Args...), impl_fn> {
static Return InferShape(
const std::vector<std::vector<int64_t>>& input_shapes,
const std::vector<std::vector<std::vector<int64_t>>>& vec_input_shapes,
const std::vector<boost::any>& attrs) {
const std::vector<paddle::any>& attrs) {
return InferShapeCallHelper<Args..., TypeTag<int>>::template InferShape<
0, 0, 0>(input_shapes, vec_input_shapes, attrs);
}
......@@ -314,7 +313,7 @@ struct InferShapeFuncImpl<Return (*)(Args...), impl_fn> {
static Return InferShape(
const std::vector<std::vector<int64_t>>& input_shapes,
const std::vector<std::vector<std::vector<int64_t>>>& vec_input_shapes,
const std::vector<boost::any>& attrs, const Args&... args) {
const std::vector<paddle::any>& attrs, const Args&... args) {
return impl_fn(args...);
}
};
......
......@@ -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)
......
......@@ -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<boost::any> custom_attrs;
std::vector<paddle::any> 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<boost::any> custom_attrs;
std::vector<paddle::any> 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];
......
......@@ -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<AttrType *>(attrs_.at(attr_name));
} catch (boost::bad_any_cast &) {
return *paddle::any_cast<AttrType *>(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<std::unique_ptr<Graph>> sub_graphs_;
std::map<std::string, boost::any> attrs_;
std::map<std::string, paddle::any> attrs_;
std::map<std::string, std::function<void(void)>> attr_dels_;
std::map<ir::Node *, std::unique_ptr<ir::Node>> nodes_;
std::unordered_set<ir::Node *> node_set_;
......
......@@ -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 <typename T>
T& Wrapper() {
try {
return *boost::any_cast<T*>(wrapper_);
} catch (boost::bad_any_cast&) {
return *paddle::any_cast<T*>(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<void(void)> wrapper_deleter_;
std::type_index wrapper_type_ = std::type_index(typeid(void));
......
......@@ -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<AttrType *>(attrs_.at(attr_name));
} catch (boost::bad_any_cast &) {
return *paddle::any_cast<AttrType *>(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<std::string, boost::any> default_attr_values) {
std::map<std::string, paddle::any> 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<std::string> required_pass_attrs_;
std::unordered_set<std::string> default_pass_attrs_;
std::unordered_set<std::string> required_graph_attrs_;
std::map<std::string, boost::any> attrs_;
std::map<std::string, paddle::any> attrs_;
std::map<std::string, std::function<void(void)>> attr_dels_;
};
......@@ -290,7 +291,7 @@ struct PassRegistrar : public Registrar {
private:
std::unordered_set<std::string> required_pass_attrs_;
std::unordered_set<std::string> required_graph_attrs_;
std::map<std::string, boost::any> default_attr_values_;
std::map<std::string, paddle::any> default_attr_values_;
std::map<std::string, std::function<void(void)>> default_attr_dels_;
};
......
......@@ -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)
......
......@@ -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<AttrType*>(attrs_.at(attr_name));
} catch (boost::bad_any_cast&) {
return *paddle::any_cast<AttrType*>(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<nvinfer1::IHostMemory> ihost_memory_;
std::unordered_map<nvinfer1::ITensor*, float> quant_dynamic_range_;
std::unordered_map<std::string, boost::any> attrs_;
std::unordered_map<std::string, paddle::any> attrs_;
std::unordered_map<std::string, std::function<void(void)>> attr_dels_;
// For dynamic shape
......
# 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
......
//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 <algorithm>
#include <typeinfo>
#include <type_traits>
// 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 <cstring>
# endif
namespace paddle
{
class any
{
public: // structors
any()
: content(0)
{
}
template<typename ValueType>
any(const ValueType & value)
: content(new holder<ValueType>(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<typename ValueType>
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<typename ValueType>
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<typename ValueType>
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<any::holder<ValueType> *>(operand->content)->held
: 0;
}
template<typename ValueType>
inline const ValueType * any_cast(const any * operand)
{
return any_cast<ValueType>(const_cast<any *>(operand));
}
template<typename ValueType>
ValueType any_cast(any & operand)
{
typedef typename std::remove_reference<ValueType>::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<nonref>::value, "!std::is_reference<nonref>::value");
nonref * result = any_cast<nonref>(&operand);
if(!result)
throw bad_any_cast();
return *result;
}
template<typename ValueType>
inline ValueType any_cast(const any & operand)
{
typedef typename std::remove_reference<ValueType>::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<nonref>::value, "!std::is_reference<nonref>::value");
return any_cast<const nonref &>(const_cast<any &>(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<typename ValueType>
inline ValueType * unsafe_any_cast(any * operand)
{
return &static_cast<any::holder<ValueType> *>(operand->content)->held;
}
template<typename ValueType>
inline const ValueType * unsafe_any_cast(const any * operand)
{
return unsafe_any_cast<ValueType>(const_cast<any *>(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
......@@ -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))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册