Skip to content

Commit a92860a

Browse files
authored
Merge pull request #15298 from panyx0718/fix
Fix python2 bug cause CE to fail
2 parents 781cd0c + 50b4ac0 commit a92860a

File tree

5 files changed

+40
-12
lines changed

5 files changed

+40
-12
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License. */
14+
15+
#pragma once
16+
17+
// workaround for Python 2 issue: https://bugs.python.org/issue17120
18+
#pragma push_macro("_XOPEN_SOURCE")
19+
#pragma push_macro("_POSIX_C_SOURCE")
20+
#undef _XOPEN_SOURCE
21+
#undef _POSIX_C_SOURCE
22+
23+
#include "pybind11/pybind11.h"
24+
25+
#pragma pop_macro("_XOPEN_SOURCE")
26+
#pragma pop_macro("_POSIX_C_SOURCE")

paddle/fluid/imperative/layer.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@
1414

1515
#pragma once
1616

17-
#include <map>
18-
#include <string>
19-
#include <vector>
17+
// clang-format off
18+
#include "paddle/fluid/framework/python_headers.h"
19+
// clang-format on
20+
21+
#include <map> // NOLINT
22+
#include <string> // NOLINT
23+
#include <vector> // NOLINT
2024

2125
#include "paddle/fluid/framework/op_desc.h"
2226
#include "paddle/fluid/framework/operator.h"
2327
#include "paddle/fluid/framework/var_desc.h"
2428
#include "paddle/fluid/platform/enforce.h"
25-
#include "pybind11/pybind11.h"
2629

2730
#include "paddle/fluid/imperative/type_defs.h"
2831

paddle/fluid/imperative/tracer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#pragma once
1616

17+
#include <map>
1718
#include <string>
1819
#include <vector>
1920

@@ -39,11 +40,10 @@ class Tracer {
3940

4041
virtual ~Tracer() {}
4142

42-
void Trace(
43-
OpBase* op,
44-
const std::map<std::string, std::vector<VarBase*>>& inputs, // NOLINT
45-
const std::map<std::string, std::vector<VarBase*>>& outputs, // NOLINT
46-
framework::BlockDesc* block, const bool stop_gradient = false);
43+
void Trace(OpBase* op,
44+
const std::map<std::string, std::vector<VarBase*>>& inputs,
45+
const std::map<std::string, std::vector<VarBase*>>& outputs,
46+
framework::BlockDesc* block, const bool stop_gradient = false);
4747

4848
std::vector<VarBase*> PyTrace(OpBase* op, const std::vector<VarBase*>& inputs,
4949
bool stop_gradient = false);

paddle/fluid/operators/py_func_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
// limitations under the License.
1414

1515
#include "paddle/fluid/operators/py_func_op.h"
16+
1617
#include <set>
1718
#include <string>
1819
#include <vector>
19-
#include "Python.h"
2020
#include "paddle/fluid/framework/op_registry.h"
2121

2222
namespace paddle {

paddle/fluid/operators/py_func_op.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
// limitations under the License.
1414

1515
#pragma once
16-
17-
#include "pybind11/pybind11.h"
16+
#include "paddle/fluid/framework/python_headers.h"
1817

1918
namespace paddle {
2019
namespace operators {

0 commit comments

Comments
 (0)