Skip to content

Commit c2fe63b

Browse files
authored
Support python3. (#502)
* Support python3. * Update summary to support python3. * Remove several unused cmake options.
1 parent a4811c7 commit c2fe63b

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

api/deploy/collect_api_info.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
package_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2323
sys.path.append(package_path)
24+
sys.path.append(os.path.join(package_path, "tests"))
2425

2526
from tests.common_import import *
2627
from common import special_op_list
@@ -119,13 +120,14 @@ def import_module():
119120

120121
def import_api(api_name):
121122
try:
122-
api = "." + api_name
123-
module = importlib.import_module(api, package='tests')
123+
module = importlib.import_module("tests." + api_name)
124124
module_name = module.__name__.split('.')
125125
API_LIST.append(module_name[1])
126+
print("Import {} successfully.".format(module.__name__))
126127
return module
127-
except Exception:
128-
print("Failed to import %s" % (api_name))
128+
except Exception as e:
129+
print("Failed to import {}: {}".format(api_name, e))
130+
return None
129131

130132

131133
def hump_to_underline(hunp_str):

api/deploy/docker_run.sh

+1-6
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,17 @@ function build_paddle(){
131131
-e "CMAKE_BUILD_TYPE=Release" \
132132
-e "PYTHON_ABI=cp27-cp27mu-gcc82" \
133133
-e "PADDLE_VERSION=0.0.0.${PADDLE_VERSION}" \
134-
-e "WITH_DOC=OFF" \
135134
-e "WITH_AVX=ON" \
136135
-e "WITH_GPU=${with_gpu}" \
137136
-e "WITH_TEST=OFF" \
138137
-e "RUN_TEST=OFF" \
139-
-e "WITH_GOLANG=OFF" \
140-
-e "WITH_SWIG_PY=ON" \
141138
-e "WITH_PYTHON=ON" \
142-
-e "WITH_C_API=OFF" \
143139
-e "WITH_STYLE_CHECK=OFF" \
144140
-e "WITH_TESTING=OFF" \
145141
-e "CMAKE_EXPORT_COMPILE_COMMANDS=ON" \
146142
-e "WITH_MKL=ON" \
147143
-e "BUILD_TYPE=Release" \
148-
-e "WITH_DISTRIBUTE=ON" \
149-
-e "WITH_FLUID_ONLY=OFF" \
144+
-e "WITH_DISTRIBUTE=OFF" \
150145
-e "CMAKE_VERBOSE_MAKEFILE=OFF" \
151146
-e "http_proxy=${HTTP_PROXY}" \
152147
-e "https_proxy=${HTTP_PROXY}" \

api/deploy/op_benchmark_unit.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
package_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2222
sys.path.append(package_path)
2323

24-
from common import special_op_list
24+
from common import special_op_list, api_param
2525

2626

2727
def parse_op_type(case_name):
@@ -51,7 +51,7 @@ def __init__(self, case_detail):
5151
self.op_type = parse_op_type(self.case_name)
5252

5353
if case_detail.get("parameters", None):
54-
parameters = case_detail["parameters"].encode("utf-8")
54+
parameters = api_param.parse_string(case_detail["parameters"])
5555
parameters = parameters.replace(" ", "")
5656
parameters = parameters.replace("\n", " ")
5757
else:

api/deploy/write_excel.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
# limitations under the License.
1616

1717
import os
18+
import sys
19+
import six
1820
import string
1921
import xlsxwriter as xlw
2022
import op_benchmark_unit
2123

22-
import sys
23-
reload(sys)
24-
sys.setdefaultencoding("utf8")
24+
if not six.PY3:
25+
reload(sys)
26+
sys.setdefaultencoding("utf8")
2527

2628

2729
def _op_filename(case_name, framework, device, task, direction):

api/tests/while_loop.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
from common_import import *
1616
from fc import FCConfig
17-
tf.compat.v1.disable_v2_behavior()
17+
try:
18+
tf.compat.v1.disable_v2_behavior()
19+
except Exception:
20+
pass
1821

1922

2023
class WhileLoopConfig(APIConfig):

0 commit comments

Comments
 (0)