Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/paddle/fluid/distributed/ps_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import sys

_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode('latin1'))
_b = (lambda x: x.encode('latin1'))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import sys

_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode('latin1'))
_b = (lambda x: x.encode('latin1'))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
Expand Down
16 changes: 2 additions & 14 deletions python/paddle/fluid/layers/rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,7 @@ def get_initial_states(self,
Variable: tensor variable[s] packed in the same structure provided \
by shape, representing the initialized states.
"""
if sys.version_info < (3, ):
integer_types = (
int,
long,
)
else:
integer_types = (int, )
integer_types = (int, )
check_variable_and_dtype(batch_ref, 'batch_ref',
['float32', 'float64', 'int32', 'int64'],
'RNNCell')
Expand All @@ -152,13 +146,7 @@ def get_initial_states(self,
batch_ref = flatten(batch_ref)[0]

def _is_shape_sequence(seq):
if sys.version_info < (3, ):
integer_types = (
int,
long,
)
else:
integer_types = (int, )
integer_types = (int, )
"""For shape, list/tuple of integer is the finest-grained objection"""
if (isinstance(seq, list) or isinstance(seq, tuple)):
if reduce(lambda flag, x: isinstance(x, integer_types) and flag,
Expand Down
5 changes: 1 addition & 4 deletions python/paddle/fluid/tests/unittests/test_fs_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
class FSTest(unittest.TestCase):

def _test_method(self, func):
if sys.version_info[0] <= 2:
args = inspect.getargspec(func).args
else:
args = inspect.getfullargspec(func).args
args = inspect.getfullargspec(func).args

a = None
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import paddle.compat as cpt
from paddle.fluid.framework import _test_eager_guard

if sys.version_info[0] == 2:
import Queue as queue
else:
import queue
import queue

from paddle.fluid.reader import multiprocess_queue_set, _cleanup, CleanupFuncRegistrar

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
from paddle.fluid.reader import _reader_process_loop
from paddle.fluid.framework import _test_eager_guard

if sys.version_info[0] == 2:
import Queue as queue
else:
import queue
import queue


def get_random_images_and_labels(image_shape, label_shape):
Expand Down
8 changes: 1 addition & 7 deletions python/paddle/nn/layer/rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,7 @@ def get_initial_states(self,
batch_ref = flatten(batch_ref)[0]

def _is_shape_sequence(seq):
if sys.version_info < (3, ):
integer_types = (
int,
long,
)
else:
integer_types = (int, )
integer_types = (int, )
"""For shape, list/tuple of integer is the finest-grained objection"""
if (isinstance(seq, list) or isinstance(seq, tuple)):
if reduce(lambda flag, x: isinstance(x, integer_types) and flag,
Expand Down
8 changes: 2 additions & 6 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,8 @@ else:
yield

# Log for PYPI
if sys.version_info > (3,0):
with open("@PADDLE_BINARY_DIR@/python/paddle/README.rst", "r", encoding='UTF-8') as f:
long_description = f.read()
else:
with open("@PADDLE_BINARY_DIR@/python/paddle/README.rst", "r")as f:
long_description = unicode(f.read(), 'UTF-8')
with open("@PADDLE_BINARY_DIR@/python/paddle/README.rst", "r", encoding='UTF-8') as f:
long_description = f.read()

# strip *.so to reduce package size
if '${WITH_STRIP}' == 'ON':
Expand Down
35 changes: 11 additions & 24 deletions tools/prune_for_jetson.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,11 @@ def find_kernel(content, pattern):

def prune_phi_kernels():
tool_dir = os.path.dirname(os.path.abspath(__file__))
if sys.version_info[0] == 3:
all_op = glob.glob(os.path.join(tool_dir,
'../paddle/phi/kernels/**/*.cc'),
recursive=True)
all_op += glob.glob(os.path.join(tool_dir,
'../paddle/phi/kernels/**/*.cu'),
recursive=True)
elif sys.version_info[0] == 2:
all_op = find_type_files(
os.path.join(tool_dir, '../paddle/phi/kernels/'), '.cc')
all_op = find_type_files(
os.path.join(tool_dir, '../paddle/phi/kernels/'), '.cu', all_op)

all_op = glob.glob(os.path.join(tool_dir, '../paddle/phi/kernels/**/*.cc'),
recursive=True)
all_op += glob.glob(os.path.join(tool_dir, '../paddle/phi/kernels/**/*.cu'),
recursive=True)

register_op_count = 0
for op_file in all_op:
Expand Down Expand Up @@ -139,18 +132,12 @@ def append_fluid_kernels():
#2. add op and kernel register
op_white_list.append("tensorrt_engine")
tool_dir = os.path.dirname(os.path.abspath(__file__))
if sys.version_info[0] == 3:
all_op = glob.glob(os.path.join(tool_dir,
'../paddle/fluid/operators/**/*.cc'),
recursive=True)
all_op += glob.glob(os.path.join(tool_dir,
'../paddle/fluid/operators/**/*.cu'),
recursive=True)
elif sys.version_info[0] == 2:
all_op = find_type_files(
os.path.join(tool_dir, '../paddle/fluid/operators/'), '.cc')
all_op = find_type_files(
os.path.join(tool_dir, '../paddle/fluid/operators/'), '.cu', all_op)
all_op = glob.glob(os.path.join(tool_dir,
'../paddle/fluid/operators/**/*.cc'),
recursive=True)
all_op += glob.glob(os.path.join(tool_dir,
'../paddle/fluid/operators/**/*.cu'),
recursive=True)

for op_file in all_op:
with io.open(op_file, 'r', encoding='utf-8') as f:
Expand Down
18 changes: 6 additions & 12 deletions tools/remove_grad_op_and_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,12 @@ def update_operator_cmake(cmake_file):

tool_dir = os.path.dirname(os.path.abspath(__file__))

if sys.version_info[0] == 3:
all_op = glob.glob(os.path.join(tool_dir,
'../paddle/fluid/operators/**/*.cc'),
recursive=True)
all_op += glob.glob(os.path.join(tool_dir,
'../paddle/fluid/operators/**/*.cu'),
recursive=True)
elif sys.version_info[0] == 2:
all_op = find_type_files(
os.path.join(tool_dir, '../paddle/fluid/operators/'), '.cc')
all_op = find_type_files(
os.path.join(tool_dir, '../paddle/fluid/operators/'), '.cu', all_op)
all_op = glob.glob(os.path.join(tool_dir,
'../paddle/fluid/operators/**/*.cc'),
recursive=True)
all_op += glob.glob(os.path.join(tool_dir,
'../paddle/fluid/operators/**/*.cu'),
recursive=True)

spec_ops = ['activation_op.cc']

Expand Down