diff --git a/paddle/fluid/framework/python_headers.h b/paddle/fluid/framework/python_headers.h new file mode 100644 index 0000000000000000000000000000000000000000..422af19a13683dc9ae6377cac1b1ab2c2ac8f96b --- /dev/null +++ b/paddle/fluid/framework/python_headers.h @@ -0,0 +1,26 @@ +/* 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 + +// workaround for Python 2 issue: https://bugs.python.org/issue17120 +#pragma push_macro("_XOPEN_SOURCE") +#pragma push_macro("_POSIX_C_SOURCE") +#undef _XOPEN_SOURCE +#undef _POSIX_C_SOURCE + +#include "pybind11/pybind11.h" + +#pragma pop_macro("_XOPEN_SOURCE") +#pragma pop_macro("_POSIX_C_SOURCE") diff --git a/paddle/fluid/imperative/layer.h b/paddle/fluid/imperative/layer.h index 86c2dc3fa4a7d03aa8f0a89a25c17656e1cd708c..daf56a521085b63926194b958094a7d170873830 100644 --- a/paddle/fluid/imperative/layer.h +++ b/paddle/fluid/imperative/layer.h @@ -14,15 +14,18 @@ #pragma once -#include -#include -#include +// clang-format off +#include "paddle/fluid/framework/python_headers.h" +// clang-format on + +#include // NOLINT +#include // NOLINT +#include // NOLINT #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/var_desc.h" #include "paddle/fluid/platform/enforce.h" -#include "pybind11/pybind11.h" #include "paddle/fluid/imperative/type_defs.h" diff --git a/paddle/fluid/imperative/tracer.h b/paddle/fluid/imperative/tracer.h index 664cb5ec1c96f4d7ef3d09c515e6ff2d5263c5fd..f225d8abe6c0635d2bdd8dba0b12c7fc3a4110db 100644 --- a/paddle/fluid/imperative/tracer.h +++ b/paddle/fluid/imperative/tracer.h @@ -14,6 +14,7 @@ #pragma once +#include #include #include @@ -39,11 +40,10 @@ class Tracer { virtual ~Tracer() {} - void Trace( - OpBase* op, - const std::map>& inputs, // NOLINT - const std::map>& outputs, // NOLINT - framework::BlockDesc* block, const bool stop_gradient = false); + void Trace(OpBase* op, + const std::map>& inputs, + const std::map>& outputs, + framework::BlockDesc* block, const bool stop_gradient = false); std::vector PyTrace(OpBase* op, const std::vector& inputs, bool stop_gradient = false); diff --git a/paddle/fluid/operators/py_func_op.cc b/paddle/fluid/operators/py_func_op.cc index a6b1c738af1daff5e3e4b1ac8e537de5adc93b76..53eff2de3e3864b0f3d61f95ab5758b65f9eecb5 100644 --- a/paddle/fluid/operators/py_func_op.cc +++ b/paddle/fluid/operators/py_func_op.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/fluid/operators/py_func_op.h" + #include #include #include -#include "Python.h" #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/py_func_op.h b/paddle/fluid/operators/py_func_op.h index 4ba06bf59857d8cc4f1c56a52627d8e768ccbf7a..5cebcd8dc0d2dcd537c7d2ce48508a6a5ee6a77d 100644 --- a/paddle/fluid/operators/py_func_op.h +++ b/paddle/fluid/operators/py_func_op.h @@ -13,8 +13,7 @@ // limitations under the License. #pragma once - -#include "pybind11/pybind11.h" +#include "paddle/fluid/framework/python_headers.h" namespace paddle { namespace operators {