Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
cebf7c60
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
cebf7c60
编写于
7月 14, 2018
作者:
Q
Qiyang Min
提交者:
GitHub
7月 14, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12095 from velconia/port_py3
Port py3
上级
f0cd493c
448ca8a4
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
87 addition
and
36 deletion
+87
-36
CMakeLists.txt
CMakeLists.txt
+6
-0
Dockerfile
Dockerfile
+1
-1
cmake/external/python.cmake
cmake/external/python.cmake
+3
-2
paddle/legacy/utils/PythonUtil.cpp
paddle/legacy/utils/PythonUtil.cpp
+6
-0
paddle/legacy/utils/PythonUtil.h
paddle/legacy/utils/PythonUtil.h
+28
-0
paddle/scripts/paddle_build.sh
paddle/scripts/paddle_build.sh
+9
-1
python/paddle/__init__.py
python/paddle/__init__.py
+6
-6
python/paddle/dataset/__init__.py
python/paddle/dataset/__init__.py
+14
-14
python/paddle/reader/__init__.py
python/paddle/reader/__init__.py
+3
-3
python/paddle/reader/decorator.py
python/paddle/reader/decorator.py
+1
-1
python/requirements.txt
python/requirements.txt
+1
-1
python/setup.py.in
python/setup.py.in
+9
-7
未找到文件。
CMakeLists.txt
浏览文件 @
cebf7c60
...
...
@@ -66,6 +66,12 @@ option(WITH_ANAKIN "Compile with Anakin library" OFF)
option
(
WITH_GRPC
"Use grpc as the default rpc framework"
${
WITH_DISTRIBUTE
}
)
option
(
WITH_BRPC_RDMA
"Use brpc rdma as the rpc protocal"
OFF
)
option
(
WITH_SYSTEM_BLAS
"Use system blas library"
OFF
)
option
(
PY_VERSION
"Compile PaddlePaddle with python3 support"
${
PY_VERSION
}
)
# PY_VERSION
if
(
NOT PY_VERSION
)
set
(
PY_VERSION 2.7
)
endif
()
# CMAKE_BUILD_TYPE
if
(
NOT CMAKE_BUILD_TYPE
)
...
...
Dockerfile
浏览文件 @
cebf7c60
...
...
@@ -80,7 +80,7 @@ RUN pip install pre-commit 'ipython==5.3.0' && \
pip
install
opencv-python
#For docstring checker
RUN
pip
install
pylint pytest astroid isort
RUN
pip
install
pylint pytest astroid isort
LinkChecker
COPY
./python/requirements.txt /root/
RUN
pip
install
-r
/root/requirements.txt
...
...
cmake/external/python.cmake
浏览文件 @
cebf7c60
...
...
@@ -18,8 +18,9 @@ ENDIF()
INCLUDE
(
python_module
)
FIND_PACKAGE
(
PythonInterp 2.7
)
FIND_PACKAGE
(
PythonLibs 2.7
)
FIND_PACKAGE
(
PythonInterp
${
PY_VERSION
}
)
FIND_PACKAGE
(
PythonLibs
${
PY_VERSION
}
)
# Fixme: Maybe find a static library. Get SHARED/STATIC by FIND_PACKAGE.
ADD_LIBRARY
(
python SHARED IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET python PROPERTY IMPORTED_LOCATION
${
PYTHON_LIBRARIES
}
)
...
...
paddle/legacy/utils/PythonUtil.cpp
浏览文件 @
cebf7c60
...
...
@@ -136,7 +136,13 @@ std::string callPythonFunc(const std::string& moduleName,
const
std
::
string
&
funcName
,
const
std
::
vector
<
std
::
string
>&
args
)
{
PyObjectPtr
obj
=
callPythonFuncRetPyObj
(
moduleName
,
funcName
,
args
);
#if PY_MAJOR_VERSION >= 3
Py_ssize_t
str_size
=
0u
;
const
char
*
str
=
PyUnicode_AsUTF8AndSize
(
obj
.
get
(),
&
str_size
);
return
std
::
string
(
str
,
(
size_t
)
str_size
);
#else
return
std
::
string
(
PyString_AsString
(
obj
.
get
()),
PyString_Size
(
obj
.
get
()));
#endif // PY_MAJOR_VERSION >= 3
}
PyObjectPtr
createPythonClass
(
...
...
paddle/legacy/utils/PythonUtil.h
浏览文件 @
cebf7c60
...
...
@@ -88,6 +88,33 @@ PyObjectPtr createPythonClass(const std::string& moduleName,
namespace
py
{
PyObjectPtr
import
(
const
std
::
string
&
moduleName
);
#if PY_MAJOR_VERSION >= 3
/**
* Cast a PyLong to int type T.
* @tparam T return type.
* @param [in] obj PyLong object.
* @param [out] ok status for casting. False if error occured. nullptr if user
* don't care is ok or not.
* @return The value of python object, or 0 if not ok.
*/
template
<
typename
T
>
T
castInt
(
PyObject
*
obj
,
bool
*
ok
=
nullptr
)
{
// Refer to https://www.python.org/dev/peps/pep-0237/, the int and long object
// were unified to long since python3
if
(
PyLong_Check
(
obj
))
{
if
(
ok
)
*
ok
=
true
;
return
(
T
)
PyLong_AsUnsignedLong
(
obj
);
}
else
{
if
(
ok
)
*
ok
=
false
;
return
(
T
)
0
;
}
}
// Convert PyAPI from 2.x to 3.x
#define PyString_FromString PyUnicode_FromString
#define PyString_AsString PyUnicode_AsUTF8
#else
/**
* Cast a PyLong or PyInt to int type T.
* @tparam T return type.
...
...
@@ -109,6 +136,7 @@ T castInt(PyObject* obj, bool* ok = nullptr) {
return
(
T
)
0
;
}
}
#endif // PY_MAJOR_VERSION >= 3
/**
* Invoke repr of python object.
...
...
paddle/scripts/paddle_build.sh
浏览文件 @
cebf7c60
...
...
@@ -78,6 +78,12 @@ function cmake_gen() {
PYTHON_FLAGS
=
"-DPYTHON_EXECUTABLE:FILEPATH=/opt/python/cp27-cp27mu/bin/python
-DPYTHON_INCLUDE_DIR:PATH=/opt/python/cp27-cp27mu/include/python2.7
-DPYTHON_LIBRARIES:FILEPATH=/opt/_internal/cpython-2.7.11-ucs4/lib/libpython2.7.so"
elif
[
"
$1
"
==
"cp35-cp35m"
]
;
then
export
LD_LIBRARY_PATH
=
/opt/_internal/cpython-3.5.1/lib/:
${
LD_LIBRARY_PATH
}
export
PATH
=
/opt/_internal/cpython-3.5.1/bin/:
${
PATH
}
export
PYTHON_FLAGS
=
"-DPYTHON_EXECUTABLE:FILEPATH=/opt/_internal/cpython-3.5.1/bin/python3
-DPYTHON_INCLUDE_DIR:PATH=/opt/_internal/cpython-3.5.1/include/python3.5m
-DPYTHON_LIBRARIES:FILEPATH=/opt/_internal/cpython-3.5.1/lib/libpython3.so"
fi
fi
...
...
@@ -108,6 +114,7 @@ function cmake_gen() {
-DWITH_CONTRIB=
${
WITH_CONTRIB
:-
ON
}
-DWITH_ANAKIN=
${
WITH_ANAKIN
:-
OFF
}
-DWITH_INFERENCE_DEMO=
${
WITH_INFERENCE_DEMO
:-
ON
}
-DPY_VERSION=
${
PY_VERSION
:-
2
.7
}
========================================
EOF
# Disable UNITTEST_USE_VIRTUALENV in docker because
...
...
@@ -136,7 +143,8 @@ EOF
-DCMAKE_EXPORT_COMPILE_COMMANDS
=
ON
\
-DWITH_CONTRIB
=
${
WITH_CONTRIB
:-
ON
}
\
-DWITH_ANAKIN
=
${
WITH_ANAKIN
:-
OFF
}
\
-DWITH_INFERENCE_DEMO
=
${
WITH_INFERENCE_DEMO
:-
ON
}
-DWITH_INFERENCE_DEMO
=
${
WITH_INFERENCE_DEMO
:-
ON
}
\
-DPY_VERSION
=
${
PY_VERSION
:-
2
.7
}
}
function
abort
(){
...
...
python/paddle/__init__.py
浏览文件 @
cebf7c60
...
...
@@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
try
:
from
version
import
full_version
as
__version__
from
version
import
commit
as
__git_commit__
from
paddle.
version
import
full_version
as
__version__
from
paddle.
version
import
commit
as
__git_commit__
except
ImportError
:
import
sys
sys
.
stderr
.
write
(
'''Warning with import paddle: you should not
sys
.
stderr
.
write
(
'''Warning with import paddle: you should not
import paddle from the source directory; please install paddlepaddle*.whl firstly.'''
)
import
reader
import
dataset
import
batch
import
paddle.
reader
import
paddle.
dataset
import
paddle.
batch
batch
=
batch
.
batch
python/paddle/dataset/__init__.py
浏览文件 @
cebf7c60
...
...
@@ -15,20 +15,20 @@
Dataset package.
"""
import
mnist
import
imikolov
import
imdb
import
cifar
import
movielens
import
conll05
import
uci_housing
import
sentiment
import
wmt14
import
wmt16
import
mq2007
import
flowers
import
voc2012
import
image
import
paddle.dataset.
mnist
import
paddle.dataset.
imikolov
import
paddle.dataset.
imdb
import
paddle.dataset.
cifar
import
paddle.dataset.
movielens
import
paddle.dataset.
conll05
import
paddle.dataset.
uci_housing
import
paddle.dataset.
sentiment
import
paddle.dataset.
wmt14
import
paddle.dataset.
wmt16
import
paddle.dataset.
mq2007
import
paddle.dataset.
flowers
import
paddle.dataset.
voc2012
import
paddle.dataset.
image
__all__
=
[
'mnist'
,
...
...
python/paddle/reader/__init__.py
浏览文件 @
cebf7c60
...
...
@@ -66,9 +66,9 @@ An example implementation for multiple item data reader creator:
TODO(yuyang18): Should we add whole design doc here?
"""
import
decorator
from
decorator
import
*
import
paddle.reader.
decorator
from
paddle.reader.
decorator
import
*
import
creator
import
paddle.reader.
creator
__all__
=
decorator
.
__all__
+
[
'creator'
]
python/paddle/reader/decorator.py
浏览文件 @
cebf7c60
...
...
@@ -20,7 +20,7 @@ __all__ = [
from
threading
import
Thread
import
subprocess
from
Q
ueue
import
Queue
from
six.moves.q
ueue
import
Queue
import
itertools
import
random
import
zlib
...
...
python/requirements.txt
浏览文件 @
cebf7c60
...
...
@@ -8,4 +8,4 @@ scipy>=0.19.0
Pillow
nltk>=3.2.2
graphviz
LinkChecker
six
python/setup.py.in
浏览文件 @
cebf7c60
...
...
@@ -17,7 +17,8 @@ def git_commit():
git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0].strip()
except:
git_commit = 'Unknown'
return git_commit
git_commit = git_commit.decode()
return str(git_commit)
def _get_version_detail(idx):
assert idx < 3, "vesion info consists of %(major)d.%(minor)d.%(patch)d, \
...
...
@@ -44,6 +45,7 @@ def is_taged():
try:
cmd = ['git', 'describe', '--exact-match', '--tags', 'HEAD', '2>/dev/null']
git_tag = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0].strip()
git_tag = git_tag.decode()
except:
return False
...
...
@@ -67,13 +69,13 @@ with_mkl = '%(with_mkl)s'
def show():
if istaged:
print
'full_version:', full_version
print
'major:', major
print
'minor:', minor
print
'patch:', patch
print
'rc:', rc
print
('full_version:', full_version)
print
('major:', major)
print
('minor:', minor)
print
('patch:', patch)
print
('rc:', rc)
else:
print
'commit:', commit
print
('commit:', commit)
def mkl():
return with_mkl
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录