提交 d2045260 编写于 作者: M minqiyang

Change visibilities of variant_visitor of pybind11

test=develop
上级 b6722918
...@@ -30,11 +30,12 @@ namespace pybind11 { ...@@ -30,11 +30,12 @@ namespace pybind11 {
namespace detail { namespace detail {
// Can be replaced by a generic lambda in C++14 // Can be replaced by a generic lambda in C++14
struct variant_caster_visitor : public boost::static_visitor<handle> { struct __attribute__((visibility("hidden"))) paddle_variant_caster_visitor
: public boost::static_visitor<handle> {
return_value_policy policy; return_value_policy policy;
handle parent; handle parent;
variant_caster_visitor(return_value_policy policy, handle parent) paddle_variant_caster_visitor(return_value_policy policy, handle parent)
: policy(policy), parent(parent) {} : policy(policy), parent(parent) {}
template <class T> template <class T>
...@@ -44,10 +45,10 @@ struct variant_caster_visitor : public boost::static_visitor<handle> { ...@@ -44,10 +45,10 @@ struct variant_caster_visitor : public boost::static_visitor<handle> {
}; };
template <class Variant> template <class Variant>
struct variant_caster; struct paddle_variant_caster;
template <template <class...> class V, class... Ts> template <template <class...> class V, class... Ts>
struct variant_caster<V<Ts...>> { struct paddle_variant_caster<V<Ts...>> {
using Type = V<Ts...>; using Type = V<Ts...>;
template <typename T> template <typename T>
...@@ -90,7 +91,7 @@ struct variant_caster<V<Ts...>> { ...@@ -90,7 +91,7 @@ struct variant_caster<V<Ts...>> {
static handle cast(Type const &src, return_value_policy policy, static handle cast(Type const &src, return_value_policy policy,
handle parent) { handle parent) {
variant_caster_visitor visitor(policy, parent); paddle_variant_caster_visitor visitor(policy, parent);
return boost::apply_visitor(visitor, src); return boost::apply_visitor(visitor, src);
} }
...@@ -101,7 +102,7 @@ struct variant_caster<V<Ts...>> { ...@@ -101,7 +102,7 @@ struct variant_caster<V<Ts...>> {
// Add specialization for concrete variant type // Add specialization for concrete variant type
template <class... Args> template <class... Args>
struct type_caster<boost::variant<Args...>> struct type_caster<boost::variant<Args...>>
: variant_caster<boost::variant<Args...>> {}; : paddle_variant_caster<boost::variant<Args...>> {};
} // namespace detail } // namespace detail
} // namespace pybind11 } // namespace pybind11
......
...@@ -86,12 +86,12 @@ bool IsCompiledWithDIST() { ...@@ -86,12 +86,12 @@ bool IsCompiledWithDIST() {
#endif #endif
} }
PYBIND11_MODULE(core) { PYBIND11_MODULE(core, m) {
// Not used, just make sure cpu_info.cc is linked. // Not used, just make sure cpu_info.cc is linked.
paddle::platform::CpuTotalPhysicalMemory(); paddle::platform::CpuTotalPhysicalMemory();
paddle::memory::allocation::UseAllocatorStrategyGFlag(); paddle::memory::allocation::UseAllocatorStrategyGFlag();
py::module m("core", "C++ core of PaddlePaddle"); m.doc() = "C++ core of PaddlePaddle";
// using framework in this function. Since it is inside a function, it will // using framework in this function. Since it is inside a function, it will
// not cause namespace pollution. // not cause namespace pollution.
...@@ -907,7 +907,6 @@ All parameter, weight, gradient are variables in Paddle. ...@@ -907,7 +907,6 @@ All parameter, weight, gradient are variables in Paddle.
}); });
BindRecordIOWriter(&m); BindRecordIOWriter(&m);
return m.ptr();
} }
} // namespace pybind } // namespace pybind
} // namespace paddle } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册