From 579449b050314c8d325c20bf75152aaed9d5bfcb Mon Sep 17 00:00:00 2001 From: dangqingqing Date: Mon, 22 Jan 2018 17:00:08 +0800 Subject: [PATCH] Update comments and revert pybind11. --- cmake/external/pybind11.cmake | 2 +- paddle/pybind/protobuf.cc | 70 +++++++++++++++++++++++++----- paddle/pybind/pybind.cc | 8 ++-- python/paddle/v2/fluid/profiler.py | 29 ++++++++----- 4 files changed, 83 insertions(+), 26 deletions(-) diff --git a/cmake/external/pybind11.cmake b/cmake/external/pybind11.cmake index ab23663695c..4e87dc49d89 100644 --- a/cmake/external/pybind11.cmake +++ b/cmake/external/pybind11.cmake @@ -26,7 +26,7 @@ ExternalProject_Add( extern_pybind ${EXTERNAL_PROJECT_LOG_ARGS} GIT_REPOSITORY "https://github.com/pybind/pybind11.git" - GIT_TAG "v2.2.1" + GIT_TAG "v2.1.1" PREFIX ${PYBIND_SOURCE_DIR} UPDATE_COMMAND "" CONFIGURE_COMMAND "" diff --git a/paddle/pybind/protobuf.cc b/paddle/pybind/protobuf.cc index d80f6b71e9b..4f959481537 100644 --- a/paddle/pybind/protobuf.cc +++ b/paddle/pybind/protobuf.cc @@ -21,24 +21,74 @@ limitations under the License. */ #include "paddle/framework/program_desc.h" #include "paddle/framework/var_desc.h" -using boost::variant; - +// Cast boost::variant for PyBind. +// Copy from +// https://github.com/pybind/pybind11/issues/576#issuecomment-269563199 namespace pybind11 { namespace detail { +// Can be replaced by a generic lambda in C++14 +struct variant_caster_visitor : public boost::static_visitor { + return_value_policy policy; + handle parent; + + variant_caster_visitor(return_value_policy policy, handle parent) + : policy(policy), parent(parent) {} + + template + handle operator()(T const &src) const { + return make_caster::cast(src, policy, parent); + } +}; + +template +struct variant_caster; + +template