/* Copyright (c) 2018 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 #include #include #include "glog/logging.h" #include "paddle/fluid/platform/variant.h" #include "pybind11/numpy.h" #include "pybind11/pybind11.h" #include "pybind11/stl.h" // Cast boost::variant for PyBind. // Copy from // https://github.com/pybind/pybind11/issues/576#issuecomment-269563199 namespace pybind11 { namespace detail { #if !defined(PYBIND11_HIDDEN) #ifdef _WIN32 #define PYBIND11_HIDDEN __declspec(dllexport) #else #define PYBIND11_HIDDEN __attribute__((visibility("hidden"))) #endif #endif // Can be replaced by a generic lambda in C++14 struct PYBIND11_HIDDEN paddle_variant_caster_visitor : public boost::static_visitor { return_value_policy policy; handle parent; paddle_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 paddle_variant_caster; template